bug-bash
[Top][All Lists]
Advanced

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

Re: Standard .bashrc needs a minor fix


From: Greg Wooledge
Subject: Re: Standard .bashrc needs a minor fix
Date: Mon, 10 May 2010 08:20:28 -0400
User-agent: Mutt/1.4.2.3i

On Sat, May 08, 2010 at 08:42:02AM -0800, Ken Irving wrote:
> bash(1) (v4.1) includes:
> 
>     OPTIONS
>         ...
>         -i        If the -i option is present, the shell is interactive.
> 
> and 
> 
>     INVOCATION
>         ...
>         PS1 is set and $- includes i if bash is interactive,  allowing
>         a shell script or a startup file to test this state.
>  
> The latter statement is ambiguous, possibly suggesting that PS1 should
> also be checked to test for an interactive shell.

I read it to mean, "If bash is interactive, then $- will include i
and PS1 will be set."  I interpret the second part as a description of
common practice, which is not necessarily the same as *best* practice.
(Or a justification of why the shell acts as it does -- "because people
expect it to be this way".)

PS1 might be set regardless of whether the shell is interactive or not,
simply because it's often exported to the environment.

I think that in the end it's all a matter of what *you* want to test for.
Consider the commands that you're trying to run (or prevent from running),
and what they do.  Consider the circumstances when they're desired, or
undesired, or safe, or unsafe; and write the scripts accordingly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]