retitle 482194 bash.bashrc, skel/.bashrc: please use $-, not $PS1, to detect 
interactive shells
# documentation
severity 482194 minor
tags 482194 =
quit

Jilles Tjoelker wrote:

> Some shells indeed seem to not set PS1 for non-interactive shells.
> However, it seems bad to rely on this to detect non-interactive shells.
> I don't see language in POSIX that says PS1 should not be set for
> non-interactive shells. Some people export PS1 in their shell startup
> files, breaking the check. The correct way to detect interactive vs
> non-interactive shells is to check if $- contains "i", for example:
>
>   case $- in
>   *i*) echo I am interactive ;;
>   *)   echo I am not interactive ;;
>   esac

That's true.  Stealing the bug.



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to