[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Standard .bashrc needs a minor fix
From: |
Mike Frysinger |
Subject: |
Re: Standard .bashrc needs a minor fix |
Date: |
Fri, 7 May 2010 15:03:57 -0400 |
User-agent: |
KMail/1.13.1 (Linux/2.6.33.2; KDE/4.4.1; x86_64; ; ) |
On Friday 07 May 2010 08:49:26 Greg Wooledge wrote:
> On Thu, May 06, 2010 at 09:30:20AM -0500, Chuck Remes wrote:
> > 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
the somewhat common test ive seen in different distros to detect interactive
shells is:
if [[ $- != *i* ]] ; then
# shell is non-interactive
return
fi
-mike
signature.asc
Description: This is a digitally signed message part.