[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"su -m" (on Mac) preserves $HOME and $USER but not ~
From: |
dabe |
Subject: |
"su -m" (on Mac) preserves $HOME and $USER but not ~ |
Date: |
Thu, 29 Oct 2015 13:02:10 -0400 (EDT) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: darwin13.4.0
Compiler: clang
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='darwin13.4.0' -DCONF_MACHTYPE='x86_64-apple-darwin13.4.0'
-DCONF_VENDOR='apple' -DLOCALEDIR='/usr/local/Cellar/bash/4.3.42/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include
-I./lib -I./lib/intl -I/private/tmp/bash20150827-50056-g82kmq/bash-4.3/lib/intl
-DSSH_SOURCE_BASHRC
uname output: Darwin triton.parabon.com 13.4.0 Darwin Kernel Version 13.4.0:
Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64 x86_64
Machine Type: x86_64-apple-darwin13.4.0
Bash Version: 4.3
Patch Level: 42
Release Status: release
Description:
I'm hoping this issue has been solved before, but I couldn't
find any answers on the 'Net...
When I "su -m", my $HOME environment variable is preserved okay
(i.e., it remains my original home directory) but often[*] '~'
is set to the target (root) user's home directory.
* - It's infuriating that /occasionally/ it DOESN'T switch to
/var/root!
Repeat-By:
Check out this copy-paste:
Thu Oct 29 12:32:22 dabe@triton:~> su -m root -c "bash"
Password:
Thu Oct 29 12:32:26 root@triton:~# echo $HOME ... ~
/Users/dabe ... /Users/dabe
Thu Oct 29 12:32:27 root@triton:~# echo $HOME ... ~
/Users/dabe ... /Users/dabe
Thu Oct 29 12:32:28 root@triton:~# echo $HOME ... ~
/Users/dabe ... /Users/dabe
Thu Oct 29 12:32:28 root@triton:~# echo $HOME ... ~
/Users/dabe ... /var/root
Thu Oct 29 12:32:28 root@triton:~# echo $HOME ... ~
/Users/dabe ... /var/root
Notice how my $HOME stays the same (good) but my ~ changes
to /var/root -- and it changes AFTER I've been logged in for
a little while! <scratching head>
Except for my $TTY and $PPID (and the date in $PS1, as well as
the $ITERM_SESSION_ID), 'set' shows all my environment / shell
variables to be identical, before and after.
It's worth pointing out that 'su -m root -c "bash -l"' works
fine, near as I can tell...
- "su -m" (on Mac) preserves $HOME and $USER but not ~,
dabe <=