help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Clarify the meaning of 's' in $- and the meaning of -s w


From: Greg Wooledge
Subject: Re: [Help-bash] Clarify the meaning of 's' in $- and the meaning of -s when invoking bash
Date: Thu, 16 Mar 2017 08:19:00 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Mar 16, 2017 at 08:27:53AM +0100, address@hidden wrote:
> It seems to me that the 's' flag is supposed to be shown in $- when
> bash reads  the standard input.

Err... not exactly.  It's included in $- if and only if the -s option
is enabled.

>     $ echo 'echo $-' | bash -s
>     hBs
> 
> However,  bash reads  the standard  input also  when there  are no  more
> arguments  after option  processing.  Example
> 
>    $ echo 'echo $-' | bash
>    hB
> 
> Can somebody explain what is the difference between running bash with
> or without '-s'?

Nothing.  Your script will not operate any differently.  The -s option,
as the man page says, "allows the positional parameters to be set when
invoking an interactive shell."

>   Another case when bash reads the standard input is when simply
>   started with the command
> 
>    $ bash

What are you actually trying to DO?

Are you trying to determine whether stdin is a terminal, inside a script,
or function?  If so, you simply use test -t 0 (or any of its equivalents).



reply via email to

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