What is a good way to do general execs?

Leo de Wit leo at ehviea.ine.philips.nl
Tue Jun 12 17:46:19 AEST 1990


In article <3449 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
|>You might also want to adjust this a bit, so the user's .profile
|>is not read into the shell [speeds up startup]:
|
|Nope.  You must be assuming that a lot of "#! /bin/sh" headers have
|"#! /bin/sh -" because the author didn't want ".profile" sourced,
|presumably along lines similar to "#! /bin/csh -f".
|
|That's not what the "-" does; it just makes sure that, if the name of
|the script begins with "-" (e.g., because somebody's trying to break
|your set-UID shell script - yes, there are other problems with set-UID
|shell scripts, but...), the shell does *not* treat it as a flag
|argument.  In that regard, it's similar to the "-b" flag in the C shell. 
|
|The Bourne shell sources ".profile" *only* for login shells (just as the
|C shell sources ".login" only for login shells - the "-f" in
|"#! /bin/csh -bf" is there to prevent it from sourcing your ".cshrc").

Nope. For the man page for 'sh': 
 
     Invocation. 
     If the first character of argument zero is -, commands are 
     read from $HOME/.profile, if such a file exists.   
 
In fact this documentation is not right either, since .profile is read
(in the current directory instead of $HOME). Login shells are started
with - prepended to the basename of their name as argv[0], so they will
read $HOME/.profile.

>From the csh man page:

     Argument list processing

     If argument 0 to the shell is `-' then this is a login
     shell. 

What it should say: if argv[0] of the shell starts with a '-', it is
treated as a login shell: $HOME/.login is sourced (cause that is what
happens).

    Leo.



More information about the Comp.unix.wizards mailing list