Re: 'cd' if HOME is unset

2023-01-02 Thread Christian Kujau
On Sun, 25 Dec 2022, Michael Cheponis wrote: > Maybe it should print "$HOME is not set" in that case? Some shells do just that, some fail silently, and some figure it out w/o $HOME set: $ for s in /bin/{sh,csh,ksh} /usr/pkg/bin/{bash,zsh}; do \ echo "### ${s}"; ${s}

Re: 'cd' if HOME is unset

2022-12-26 Thread Robert Elz
zsh -c cd | $(no change in directory, no error msg) No error message, yes, but are you sure there was no change in directory? (Even if that change was into the directory it started from). jacaranda$ (cd /; unset HOME; zsh -c 'cd; pwd') /home/kre Looks like it changed directory to me (from

Re: 'cd' if HOME is unset

2022-12-26 Thread Michael Cheponis
Well, as a zsh user: $ echo $HOME /usr/mac $ unset HOME $ echo $HOME $ zsh -c cd $(no change in directory, no error msg) also: $ HOME=/usr/mac $ echo $HOME /usr/mac $ (unset HOME; zsh -c cd) $ (no error msg) in all

Re: 'cd' if HOME is unset

2022-12-26 Thread Robert Elz
Date:Sun, 25 Dec 2022 15:33:57 -0800 From:Michael Cheponis Message-ID: | Maybe it should print "$HOME is not set" in that case? Did you try it? It is easy... (unset HOME; sh -c cd) or use ksh (or some other shell) instead of sh to test i

Re: 'cd' if HOME is unset

2022-12-26 Thread Michael Cheponis
Maybe it should print "$HOME is not set" in that case? On Sun, Dec 25, 2022 at 2:52 PM Valery Ushakov wrote: > On Sat, Dec 24, 2022 at 22:32:22 -0500, Jan Schaumann wrote: > > > Robert Elz wrote: > > > Why bother? > > > > I happily admit that it's a rare edge case. I simply > > find it

Re: 'cd' if HOME is unset

2022-12-25 Thread Valery Ushakov
On Sat, Dec 24, 2022 at 22:32:22 -0500, Jan Schaumann wrote: > Robert Elz wrote: > > Why bother? > > I happily admit that it's a rare edge case. I simply > find it surprising that 'cd' gives up if HOME is > unset. Seems unintuitive to me. Some would say, "gives up", some would say it makes

Re: 'cd' if HOME is unset

2022-12-24 Thread Robert Elz
Date:Sat, 24 Dec 2022 22:32:22 -0500 From:Jan Schaumann Message-ID: | I happily admit that it's a rare edge case. I simply | find it surprising that 'cd' gives up if HOME is | unset. Seems unintuitive to me. It is how it is defined to work, and always has

Re: 'cd' if HOME is unset

2022-12-24 Thread Jan Schaumann
Robert Elz wrote: > Why bother? I happily admit that it's a rare edge case. I simply find it surprising that 'cd' gives up if HOME is unset. Seems unintuitive to me. -Jan

Re: 'cd' if HOME is unset

2022-12-24 Thread Robert Elz
Why bother?It is already clear that one cannot depend upon this working, and nothing normally should ever have HOME unset, unless that is done deliberately (perhaps even to prevent a simple "cd" from going there). kre

Re: 'cd' if HOME is unset

2022-12-24 Thread Jan Schaumann
Jan Schaumann wrote: > "A common extension when HOME is undefined is to get > the login directory from the user database for the > invoking user. This does not occur on System V > implementations." > > I'm surprised that /bin/sh does not use the user's > home directory from getpwuid() in that

'cd' if HOME is unset

2022-12-19 Thread Jan Schaumann
o get the login directory from the user database for the invoking user. This does not occur on System V implementations." I'm surprised that /bin/sh does not use the user's home directory from getpwuid() in that case: $ pwd /tmp $ unset HOME $ cd cd: HOME not set $ pwd /tmp $ This is the sam