delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/04/22/21:30:33

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=2.9 required=5.0 tests=AWL,BAYES_05,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-InterSystems: Sent from InterSystems
X-InterSystems: Sent from InterSystems
X-InterSystems: Sent from InterSystems
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
MIME-Version: 1.0
Message-Id: <20110423013010.942639D5A05@mail2.intersystems.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/Cy=
gwin/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.=20
Is this expected behavior?  Is there a way using sh to always avoid the err=
or 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019