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} -c "cd /tmp; unset HOME; c

Re: 'cd' if HOME is unset

2022-12-26 Thread Robert Elz
Date:Mon, 26 Dec 2022 10:41:25 -0800 From:Michael Cheponis Message-ID: | Well, as a zsh user: What zsh does you'd need to take up with zsh developers. But it is one of 2 shells I tested which don't require HOME to be set for "cd". zsh I am not all that surprise

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 c

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 it. Script star

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 surpris

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 you

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 bee

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 ca

'cd' if HOME is unset

2022-12-19 Thread Jan Schaumann
Hello, POSIX requires that the 'cd' command use the $HOME environment variable (if that is set) when no operand is given. It explicitly notes that behavior of 'cd' with no operand when $HOME is unset is implementation defined. It then notes: "A common extension when HOME is undefined is to get t