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

-- 
Jilles Tjoelker



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to