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

Re: How does Squeeze initialize PS1 ?



On Fri, Aug 20, 2010 at 6:36 PM, Paul E Condon
<pecondon@mesanetworks.net> wrote:
> I'm debugging some bash scripts and reading the scripts that come as
> part of Squeeze installation. I find several places where there are
> statements the set a value from variable PS1, BUT all of them seem
> to be in scripts that only get executed if PS1 is already non-empty.
> i.e. they are after a statement
> [ -z "$PS1" ] && return
> which, I think, executes return if PS1 is empty.
>
> A related question:
> The comment just before the above line of code is:
> "# If not running interactively, don't do anything"
>
> For me, the implication of this comment is that a non-empty PS1 IS
> the defining characteristic of 'running interactively', but I would
> have thought 'interactive' should be characterized by having a tty
> attached to sysin and sysout for communication to a 'user'.
>
> I can imagine that a non-empty PS1 is used as an indicator, in which
> case whatever code that actually sets up the tty also sets PS1 to
> some minimal non-empty value like a single space or a dot, but is
> this actually the way it works, and where is it?
>
> Where can I read about these issues?

>From "man bash" (not being obnoxious)

An interactive shell is one started without non-option arguments and
without the -c option whose standard input and error are both connected
to terminals (as determined by isatty(3)), or one started with the -i
option. PS1 is set and $- includes i if bash is interactive, allowing
a shell script or a startup file to test this state.


Reply to: