NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 'cd' if HOME is unset



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 cases, directory does not change when HOME is not defined.


On Mon, Dec 26, 2022 at 9:47 AM Robert Elz <kre%munnari.oz.au@localhost> wrote:
    Date:        Sun, 25 Dec 2022 15:33:57 -0800
    From:        Michael Cheponis <michael.cheponis%gmail.com@localhost>
    Message-ID:  <CAOaX04M_e8Ue9FH0M88Zq2A-yPoS8zt1tvLzomiKpJx=5rWgoA%mail.gmail.com@localhost>

  | 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 started on Tue Dec 27 00:01:34 2022
jacaranda$ (unset HOME; sh -c cd)
cd: HOME not set
jacaranda$ (unset HOME; ksh -c cd)
ksh: cd: no home directory (HOME not set)
jacaranda$ exit

Script done on Tue Dec 27 00:03:06 2022


Note HOME  not $HOME  is not set, $HOME is, if
HOME is set, a pathname, or if HOME is not set, "",
neither of which makes any sense to describe as 'not set'.

kre


Home | Main Index | Thread Index | Old Index