This is the mail archive of the
cygwin
mailing list for the Cygwin project.
bash 4.1.10: SHELLOPTS questions -- different behavior between sh and bash
- From: Len Giambrone <Len dot Giambrone at intersystems dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Cc: Len Giambrone <Len dot Giambrone at intersystems dot com>
- Date: Fri, 22 Apr 2011 21:30:07 -0400
- Subject: 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
./bar
$ cat bar
echo bar
$ set -o igncr
$ export SHELLOPTS
$ sh bar
bar
$ bash bar
bar
$ sh foo
foo
sh: SHELLOPTS: readonly variable
bar
$ bash foo
foo
bar
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?
-Len
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple