Greg Wooledge wrote:
On Thu, May 06, 2010 at 09:30:20AM -0500, Chuck Remes wrote:
The standard .bashrc contains a line of code that precludes certain
scripts from executing. It has to do with the logic for checking if
the session is interactive.
There's no such thing as a "standard .bashrc", at least not from the
point of view of a bash bug mailing list. Files like .bashrc are
supplied by the OS vendor, or created by the user.
e.g.
[ -z "$PS1" ] && return
That's certainly *not* how I'd write that check. If the goal is to
protect a block of commands from running when the shell is invoked
without a terminal, then I'd prefer this:
if [ -t 1 ]; then
# All your terminal commands go here
stty kill ^u susp ^z intr ^c
...
fi
I'm doing it like this:
it [[ ${-#*i} = $- || ! -t 0 ]]
# non-interactive stuff here
...
else
# interactive stuff here
stty ...
...
fi
bye, Jojo