[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
exported SHELLOPTS gives error message from sh
From: |
Len Giambrone |
Subject: |
exported SHELLOPTS gives error message from sh |
Date: |
Thu, 6 Oct 2011 14:54:56 -0400 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: darwin10.8.0
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='darwin10.8.0' -DCONF_MACHTYPE='i386-apple-darwin10.8.0'
-DCONF_VENDOR='apple' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include -I./lib -I./lib/intl
-I/Users/lgiambro/admin/dists/bash-4.1/lib/intl -g -O2
uname output: Darwin Valinor.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun
7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64
Machine Type: i386-apple-darwin10.8.0
Bash Version: 4.1
Patch Level: 10
Release Status: release
Description:
The man page states:
SHELLOPTS
A colon-separated list of enabled shell options. Each word in
the list is a valid argument for the -o option to the set
builtin command (see SHELL BUILTIN COMMANDS below). The options
appearing in SHELLOPTS are those reported as on by set -o. If
this variable is in the environment when bash starts up, each
shell option in the list will be enabled before reading any
startup files. This variable is read-only.
This works great if I use only bash:
$ bash --version
GNU bash, version 4.1.10(2)-release (i386-apple-darwin10.8.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
$ cat foo
echo foo
./bar
$ cat bar
set -o | grep noclobber
$ set -o noclobber
$ export SHELLOPTS
$ bash foo
foo
noclobber on
But it doesn't work if I use sh instead:
$ sh --version
GNU bash, version 4.1.10(2)-release (i386-apple-darwin10.8.0)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
$ sh foo
foo
sh: SHELLOPTS: readonly variable
noclobber off
It also outputs an annoying error message that is cluttering our logfiles.
I suspect this is because sh is always run in POSIX mode?
Many people now use sh and bash interchangeably. Is there a way to get the
same behavior as when called with the name "bash"?
We have "sh" all over our scripts, but we need it to act the same as "bash".
Is there a better way to have settings in SHELLOPTS propagate to daughter
shells?
-Len