[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interactive test faulty

From: Greg Wooledge
Subject: Re: interactive test faulty
Date: Thu, 22 Mar 2012 13:42:30 -0400
User-agent: Mutt/

On Thu, Mar 22, 2012 at 12:06:24PM +0000, Tim Dickson wrote:
> put echo "$-" in a oneline bash script called test and make executable
> *./test*
> output is *ehB*
> this should include the "i" in the output as the shell _is_ interactive

No, a script is by definition a non-interactive shell.

> *echo hi|./test *
> output is *e*
> this is as expected input is not from a tty

Are you confusing "interactive" with "has a terminal as standard input"?

> either the functionality of bash is not correct or the meaning of 
> interactive is not clear.

>From the manual,

      An interactive shell is one started without non-option arguments and
      without the -c option whose standard input and error are both
      connected to terminals (as determined by isatty(3)), or one started
      with the -i option.

If you run a script like ./test, then the kernel invokes bash with the
script name as a non-option argument (i.e., "/bin/bash ./test").  So
that shell is not interactive.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]