On Sun, Feb 27, 2005 at 10:38:51PM +0100, Marco d'Itri wrote: > On Feb 27, Gerrit Pape <[EMAIL PROTECTED]> wrote: > > Do you have an example where such a test on $PS1 is used? I'm unsure > Yes, I have a script which must behave differently if started from init > or by an user from the shell. $- does not work.
Hm, I fail to see how this works if I start a bash script from bash login shell, PS1 is unset just as $- doesn't contain an i, what am I missing?: # PS1='# ' # cat >s <<\EOT > #!/bin/bash > test -z "$PS1" && echo unset || echo "$PS1" > echo $- > EOT # chmod 700 s # ./s unset hB # Wouldn't it be better to check for the environment provided by sysvinit (RUNLEVEL, PREVLEVEL, INIT_VERSION), or to check $PPID? Regards, Gerrit. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]