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

[Xen-devel] [OSSTEST PATCH 3/3] Shell fixup: Use bash in posix mode



When bash is started as /bin/sh it run in posix compatibility mode.
But when invoked as /bin/bash it does some things ... differently.

Most notably:

   Subshells spawned to execute command substitutions inherit the
   value of the -e option from the parent shell.  When not in posix
   mode, bash clears the -e option in such subshells.

It is a mystery why anyone thought the `non-posix' behaviour was
desirable.  One effect in practice is that osstest's cr-daily-branch
can blunder on if one of its version fetches fails.

AFAICT the only documented way to get rid of this anomalous behaviour
is to switch bash to posix mode.  I have read through the wheezy
bash(1) manpage and searched for posix, and the following behavioural
differences are described:

 * Differences in interative startup (not relevant to us).
 * Minor (irrelevant) differences in which startup files are read
   during noninteractive startup.  (Eg, BASH_ENV not honoured.)
 * Differences to the parsing of invocations of `time'
 * `test a == b' may be unsupported (but it's wrong and we say `=')
 * -e not inherited by some subshells (this is what I am trying to fix)
 * `.' and `source' do not search the cwd.
 * `set' with no arguments does not print shell functions etc.

So I think, with the previous patch, that these changes are all
desirable or at least harmless.

I have not added `set -o posix' to shell script fragments invoked by
various scripts (eg Perl and Tcl scripts).  Those scripts might be
processed by bash if /bin/sh is bash, but when is invoked as sh it
runs in posix mode anyway.

I have done some ad-hoc testing but it seems like much of this is
difficult to test.  I suggest we push it at a time when we can keep a
close eye on the behaviour.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 ap-fetch-version                        |    2 +-
 ap-fetch-version-baseline               |    2 +-
 ap-fetch-version-baseline-late          |    2 +-
 ap-fetch-version-old                    |    2 +-
 ap-print-url                            |    2 +-
 ap-push                                 |    2 +-
 ap-qemu-revision                        |    2 +-
 ap-qemu-url                             |    2 +-
 cr-all-branch-statuses                  |    2 +-
 cr-daily-branch                         |    2 +-
 cr-for-branches                         |    2 +-
 cr-try-bisect                           |    2 +-
 cr-try-bisect-adhoc                     |    2 +-
 cri-getprevxenbranch                    |    2 +-
 invoke-daemon                           |    4 +++-
 make-distros-flight                     |    2 +-
 make-flight                             |    2 +-
 mg-adjust-flight-makexrefs              |    2 +-
 mg-all-branch-statuses                  |    2 +-
 mg-branch-setup                         |    2 +-
 mg-cpu-microcode-update                 |    2 +-
 mg-debian-installer-update              |    2 +-
 mg-debian-installer-update-all          |    2 +-
 mg-execute-flight                       |    2 +-
 mg-pxe-loader-update                    |    2 +-
 mg-update-live                          |    2 +-
 sa-forget-flight                        |    2 +-
 sa-init-db                              |    2 +-
 sg-hg-heads                             |    2 +-
 standalone                              |    2 +-
 standalone-generate-dump-flight-runvars |    2 +-
 standalone-reset                        |    2 +-
 32 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/ap-fetch-version b/ap-fetch-version
index 086aa62..6fa7588 100755
--- a/ap-fetch-version
+++ b/ap-fetch-version
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 . ./cri-lock-repos
diff --git a/ap-fetch-version-baseline b/ap-fetch-version-baseline
index 8889d1e..2e42508 100755
--- a/ap-fetch-version-baseline
+++ b/ap-fetch-version-baseline
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 
diff --git a/ap-fetch-version-baseline-late b/ap-fetch-version-baseline-late
index 3db443d..9856ec9 100755
--- a/ap-fetch-version-baseline-late
+++ b/ap-fetch-version-baseline-late
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 new=$2
diff --git a/ap-fetch-version-old b/ap-fetch-version-old
index 9d5487a..66d51f8 100755
--- a/ap-fetch-version-old
+++ b/ap-fetch-version-old
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 . ./cri-lock-repos
diff --git a/ap-print-url b/ap-print-url
index 1b178c7..4088852 100755
--- a/ap-print-url
+++ b/ap-print-url
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 . ./cri-lock-repos
diff --git a/ap-push b/ap-push
index ea21887..d2195f2 100755
--- a/ap-push
+++ b/ap-push
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -ex
+set -ex -o posix
 
 branch=$1
 revision=$2
diff --git a/ap-qemu-revision b/ap-qemu-revision
index de105ca..d08cffe 100755
--- a/ap-qemu-revision
+++ b/ap-qemu-revision
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 xenbranch=$1
 xenrevision=$2
diff --git a/ap-qemu-url b/ap-qemu-url
index 6ed704a..61598f6 100755
--- a/ap-qemu-url
+++ b/ap-qemu-url
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 xenbranch=$1
 
diff --git a/cr-all-branch-statuses b/cr-all-branch-statuses
index f4ed46e..46028ba 100755
--- a/cr-all-branch-statuses
+++ b/cr-all-branch-statuses
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -ex
+set -ex -o posix
 
 . ./cri-args-hostlists
 branch=$1; shift
diff --git a/cr-daily-branch b/cr-daily-branch
index 06f4b38..c7cc33b 100755
--- a/cr-daily-branch
+++ b/cr-daily-branch
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -ex
+set -ex -o posix
 
 . ./cri-args-hostlists
 . ./ap-common
diff --git a/cr-for-branches b/cr-for-branches
index 8d5748b..757045d 100755
--- a/cr-for-branches
+++ b/cr-for-branches
@@ -20,7 +20,7 @@
 
 
 
-set -e
+set -e -o posix
 
 export FOR_LOGFILE="$*"
 
diff --git a/cr-try-bisect b/cr-try-bisect
index 06c4940..2a5fe09 100755
--- a/cr-try-bisect
+++ b/cr-try-bisect
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -ex
+set -ex -o posix
 
 . ./cri-bisect
 . ./cri-args-hostlists
diff --git a/cr-try-bisect-adhoc b/cr-try-bisect-adhoc
index 4ff8b8c..5f8b7e1 100755
--- a/cr-try-bisect-adhoc
+++ b/cr-try-bisect-adhoc
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -ex
+set -ex -o posix
 
 export OSSTEST_BLESSING=adhoc
 
diff --git a/cri-getprevxenbranch b/cri-getprevxenbranch
index 308b0c7..a70138e 100755
--- a/cri-getprevxenbranch
+++ b/cri-getprevxenbranch
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 xenbranch=$1
 p=
diff --git a/invoke-daemon b/invoke-daemon
index 5fab1da..ad1434a 100755
--- a/invoke-daemon
+++ b/invoke-daemon
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash
 
 # This is part of "osstest", an automated testing framework for Xen.
 # Copyright (C) 2009-2013 Citrix Inc.
@@ -16,6 +16,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+set -e -o posix
+
 if [ -e $HOME/.xen-osstest/settings ]; then
      source $HOME/.xen-osstest/settings
 fi
diff --git a/make-distros-flight b/make-distros-flight
index 697a171..90e28c3 100755
--- a/make-distros-flight
+++ b/make-distros-flight
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 xenbranch=$2
diff --git a/make-flight b/make-flight
index 8dc4e64..8c75a9c 100755
--- a/make-flight
+++ b/make-flight
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 xenbranch=$2
diff --git a/mg-adjust-flight-makexrefs b/mg-adjust-flight-makexrefs
index ebbac15..ec555bc 100755
--- a/mg-adjust-flight-makexrefs
+++ b/mg-adjust-flight-makexrefs
@@ -22,7 +22,7 @@
 #             passing --debug in REF-CONDS too)
 #   -n      Dry run: do not actually run cs-adjust-flight
 
-set -e
+set -e -o posix
 
 exec 3>/dev/null
 verbose=''
diff --git a/mg-all-branch-statuses b/mg-all-branch-statuses
index 74dc09a..d3e437f 100755
--- a/mg-all-branch-statuses
+++ b/mg-all-branch-statuses
@@ -25,7 +25,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 . ./cri-common
 
diff --git a/mg-branch-setup b/mg-branch-setup
index f8bcb2e..6a9bd3f 100755
--- a/mg-branch-setup
+++ b/mg-branch-setup
@@ -15,7 +15,7 @@
 #  - create any input/output tree on xenbits
 #  - run any test flights (obviously)
 
-set -e
+set -e -o posix
 
 fail () { echo >&2 "$*"; exit 1; }
 badusage () { fail 'bad usage'; }
diff --git a/mg-cpu-microcode-update b/mg-cpu-microcode-update
index 4d51dfb..1032025 100755
--- a/mg-cpu-microcode-update
+++ b/mg-cpu-microcode-update
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 . ./cri-getconfig
 . ./mgi-common
diff --git a/mg-debian-installer-update b/mg-debian-installer-update
index 6070b8a..7e3fb20 100755
--- a/mg-debian-installer-update
+++ b/mg-debian-installer-update
@@ -19,7 +19,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 . ./cri-getconfig
 . ./mgi-common
diff --git a/mg-debian-installer-update-all b/mg-debian-installer-update-all
index 1bbaef7..4e76a69 100755
--- a/mg-debian-installer-update-all
+++ b/mg-debian-installer-update-all
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 . ./cri-getconfig
 
diff --git a/mg-execute-flight b/mg-execute-flight
index 0d8c792..8b2c21c 100755
--- a/mg-execute-flight
+++ b/mg-execute-flight
@@ -29,7 +29,7 @@ usage () { cat <<END
 END
 }
 
-set -e
+set -e -o posix
 
 publish=false
 
diff --git a/mg-pxe-loader-update b/mg-pxe-loader-update
index 9774350..e0e347d 100755
--- a/mg-pxe-loader-update
+++ b/mg-pxe-loader-update
@@ -21,7 +21,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 . ./cri-getconfig
 . ./mgi-common
diff --git a/mg-update-live b/mg-update-live
index f1d24cd..3ff7ffa 100755
--- a/mg-update-live
+++ b/mg-update-live
@@ -22,7 +22,7 @@
 #  cd ~osstest
 #  for f in branches/*.git; do ./update-live 
3c464fbf8a05b24f4afb7e58bcf4ae77fbb7ad0c $f; done
 
-set -e
+set -e -o posix
 bad="$1"
 dir="$2"
 
diff --git a/sa-forget-flight b/sa-forget-flight
index 8b005f1..1c3ecb2 100755
--- a/sa-forget-flight
+++ b/sa-forget-flight
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 usage(){
        cat <<END
diff --git a/sa-init-db b/sa-init-db
index 37ab4be..bd9aa4a 100755
--- a/sa-init-db
+++ b/sa-init-db
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 usage(){
        cat <<END
diff --git a/sg-hg-heads b/sg-hg-heads
index 41ec734..b2dd601 100755
--- a/sg-hg-heads
+++ b/sg-hg-heads
@@ -21,7 +21,7 @@
 #  where COMMAND ARGS SCRIPT
 #  runs shell script SCRIPT in an appropriate directory and place
 
-set -e
+set -e -o posix
 
 result=`"$@" 'hg heads --template '\''{node|short}\n'\'''`
 lines=`printf '%s\n' "$result" | wc -l`
diff --git a/standalone b/standalone
index 9383d72..168a46c 100755
--- a/standalone
+++ b/standalone
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 usage() {
     cat >&2 <<EOF
diff --git a/standalone-generate-dump-flight-runvars 
b/standalone-generate-dump-flight-runvars
index da3c0f8..d113927 100755
--- a/standalone-generate-dump-flight-runvars
+++ b/standalone-generate-dump-flight-runvars
@@ -24,7 +24,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 set -o pipefail
 
diff --git a/standalone-reset b/standalone-reset
index 0a69915..e58ba68 100755
--- a/standalone-reset
+++ b/standalone-reset
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set -e
+set -e -o posix
 
 usage(){
        cat <<END
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.