Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Change directory on invocation of zsh



On Sun, 17 Oct 2004, Michael Prokop wrote:

> * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> [20041017 10:13]:
> >   if (( EUID == 0 )); then
> >      export HOME=/root
> >   else
> >      export HOME=/home/$LOGNAME
> >   fi
> 
> /etc/zsh/zshrc:cd:22: no such file or directory: /home/LOGIN
> $ echo $LOGNAME
> LOGIN

Hm.  This means that one of the following occurred:

- getlogin() returned "LOGIN"

- getlogin() returned empty or null, and getpwuid() returned an entry for
  the user named "LOGIN"

I'd have to guess this is a side-effect of autologin?  Does it run as the
user "LOGIN"?

> I can't find the reason for this behaviour (inittab entries are the
> same and behaviour seems to change when booting system serveral
> times), but using `id -un` instead of $LOGNAME seems to fix it.

If you can't figure out how to get it to be consistent, I'd suggest adding
to /etc/zsh/zshenv this snippet:

  [[ $LOGNAME == LOGIN ]] && LOGNAME=$(id -un)

Do that before the EUID/HOME snippet.  Other things may be depending on 
LOGNAME being set correctly, too.



Messages sorted by: Reverse Date, Date, Thread, Author