This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bash 4.1.10: SHELLOPTS questions -- different behavior between sh and bash

Greetings.  I'm running the latest (as of a few days ago) Cygwin and bash.

Cygwin Package Information
Package              Version        Status
bash                 4.1.10-4       OK
cygwin               1.7.9-1        OK

If I set -o igncr, and then export SHELLOPTS as stated in /usr/share/doc/Cygwin/bash.README:

4d. Added in the bash-3.2-2 release: export the environment variable
SHELLOPTS with igncr included in it.  It is read-only from within bash,
but you can set it before invoking bash; once in bash, it auto-tracks the
current state of 'set -o igncr'.  If exported, then all bash child
processes inherit the same option settings; with the exception added in
3.2.9-11 that certain interactive options are not inherited in
non-interactive use.

I get different behavior depending on whether I use bash or sh.  Further, I only get an error message
if I have a script that calls a script:

$ cat foo
echo foo

$ cat bar
echo bar

$ set -o igncr
$ export SHELLOPTS

$ sh bar
$ bash bar

$ sh foo
sh: SHELLOPTS: readonly variable
$ bash foo

I know bash and sh are the same program which behaves differently depending on how it's called. 
Is this expected behavior?  Is there a way using sh to always avoid the error message?


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]