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