Subject: Re: Root .profile
To: NetBSD-current Users <current-users@netbsd.org>
From: Brian D Chase <bdc@world.std.com>
List: current-users
Date: 04/11/1999 11:16:34
On Sun, 11 Apr 1999, Curt Sampson wrote:
> On Sun, 11 Apr 1999, Brian D Chase wrote:

> > Just noticed that on my diskless setup during a fresh install of 1.4_ALPHA
> > that things are a little askew.  The /.profile assumes the presence of
> > `/usr/bin/id' which initially isn't available since my /usr won't get
> > mounted until after I've configured my /etc/rc.conf.
> 
> Charles just fixed this by removing the call to ID. I'm not sure
> a better fix wouldn't be along the lines of `test -x /usr/bin/id
> && id'.

Yeah, testing for the existence of /usr/bin/id would be fine with me. If
there's no /usr/bin/id (or I guess if more correctly if there's no
/usr/bin) would it be safe to assume that you're running single user or at
least as the super-user?  But I suppose even if okay, that would be sort
of a side-effect hack.

> But there's something more I want to point out about this .profile:
> it only works for you initial shell, and the prompt and shell
> functions get lost in subshells. What do you think about doing it
> the way I've been doing it for a few years, which is to add
> 
>     ENV=$HOME/.shrc; export ENV
> 
> to the .profile, and then put something similar to the following
> in .shrc:
> 
>     set -o vi
>     alias lf='ls -CF'
>     alias ll='ls -l'
>     PS1="$(hostname -s)"
>     if [ -x /usr/bin/id -a $(/usr/bin/id -u) -eq 0 ]; then
> 	    PS1="$PS1 # "
>     else
> 	    PS1="$PS1 $ "
>     fi
> 
> This sort of thing used to be annoying with `make -j' because every
> time it spawned a subshell with -x, the $ENV file would be printed
> out, but I fixed that recently by adding an option to /bin/sh not
> to print the $ENV file as it executes it.

Oh, I don't know.  In the case of /root/.profile, something like the above
would probably be alright. I sort of see /.profile as a special case
though since it is only used in single user mode.

My preferences lean towards keeping things as simple as possible.  I'd
probably strip down /.profile making it much less sophisticated than
/root/.profile unless there are reasons for keeping the two identical.

-brian.
---
Brian "JARAI" Chase | http://world.std.com/~bdc/ | VAXZilla LIVES!!!