]> xenbits.xensource.com Git - osstest.git/commitdiff
Shell fixup: Use bash in posix mode
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 24 Sep 2015 17:03:00 +0000 (18:03 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 29 Sep 2015 13:33:15 +0000 (14:33 +0100)
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@eu.citrix.com>
32 files changed:
ap-fetch-version
ap-fetch-version-baseline
ap-fetch-version-baseline-late
ap-fetch-version-old
ap-print-url
ap-push
ap-qemu-revision
ap-qemu-url
cr-all-branch-statuses
cr-daily-branch
cr-for-branches
cr-try-bisect
cr-try-bisect-adhoc
cri-getprevxenbranch
invoke-daemon
make-distros-flight
make-flight
mg-adjust-flight-makexrefs
mg-all-branch-statuses
mg-branch-setup
mg-cpu-microcode-update
mg-debian-installer-update
mg-debian-installer-update-all
mg-execute-flight
mg-pxe-loader-update
mg-update-live
sa-forget-flight
sa-init-db
sg-hg-heads
standalone
standalone-generate-dump-flight-runvars
standalone-reset

index 086aa6295721142462ef0d268e0251ac34925f85..6fa75880f9852159f7f695c743689a27071d6186 100755 (executable)
@@ -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
index 8889d1eb527013658c6a3311d375b2f9906976bd..2e42508e7e19f5d1d3f87e5ac4e42f8a67b23520 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 branch=$1
 
index 3db443d6ea88075ee28148b5a6fd636634419bd9..9856ec9337a7515ac89c3ff33189fd486bc9bcbe 100755 (executable)
@@ -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
index 9d5487a1198274e8267fe98cf315fc7cca4714c1..66d51f8793d6f6d8860f055c74863a69d06f72d1 100755 (executable)
@@ -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
index 1b178c7efd24cf7d9e2585e86810344d6635f6f5..408885207ee9e9c01a5fefdb8048bd07ae3cf47b 100755 (executable)
@@ -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 ea2188733fb1b00ca901479f442277ce5e3bf0e2..d2195f2118903abf4377d3325639a45cd2a394a8 100755 (executable)
--- 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
index de105caa080caf0ee61cfe319c4be015d2a0f77f..d08cffe49fad331b95ddc688957c55ed5699eec6 100755 (executable)
@@ -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
index 6ed704a5fd5985a98dccf0436088b9e3990de364..61598f66413e6cc146d6edc09bd4b25e4787a260 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set -e
+set -e -o posix
 
 xenbranch=$1
 
index f4ed46eb9094aa8051b40bca5101b1519f61a7da..46028ba076be41529857ca2e849bdc33ab0e5248 100755 (executable)
@@ -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
index 06f4b38f0eded071a23dd3a548719bb4844db46d..c7cc33b480c97aa8d1a53247e5867dc898ad6d7b 100755 (executable)
@@ -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
index 8d5748b06b3069e6d5aee9af54aec8033c0131f6..757045d5b018948667d679cf7678152af316a6ba 100755 (executable)
@@ -20,7 +20,7 @@
 
 
 
-set -e
+set -e -o posix
 
 export FOR_LOGFILE="$*"
 
index 06c494098b4a6395be9136024b3e433d01cd9f8b..2a5fe099cb034f8a693d91fb2dae64cbd4910274 100755 (executable)
@@ -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
index 4ff8b8c8be740801d993d5ee8c57d4912a41b25b..5f8b7e1fce59da34979fa845379308d40c1445e0 100755 (executable)
@@ -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
 
index 308b0c786db3c76ef1e0baa14c9842ad8d909337..a70138e1e632daadede8c0ad05a3d4f74de03104 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 xenbranch=$1
 p=
index 5fab1da7d6b4250f5c297ca462d5b1ac52c03d8b..ad1434aa610a8729b63049408f6c1a864f4bc58d 100755 (executable)
@@ -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
index 697a17158120457534b4b8a088752abfeaab7226..90e28c32465e894138d160e7a506a10fe385f6b2 100755 (executable)
@@ -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
index 8dc4e64cbb98c6ebbdb23f2c0dc995628f53e94e..8c75a9c6f72a9b8b55f2b470ba7ce384d6e0df07 100755 (executable)
@@ -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
index ebbac159f6bf6f7d2bc1744134e79111441271d6..ec555bc3baca82adcf8288b2214b84e493598297 100755 (executable)
@@ -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=''
index 74dc09a31dd17c15057e923e75a25d18553e649e..d3e437f6330df71935e85f6caa10a85941d9b6f4 100755 (executable)
@@ -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
 
index f8bcb2ee392687a401a0b661e97c9a615489078b..6a9bd3fa7336340a0b6458f400e9011546d9ddff 100755 (executable)
@@ -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'; }
index 4d51dfbcc993606d454774fd95c9c8435d69ad02..1032025f1b3158f02758076f4dab4587086c64dd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 . ./cri-getconfig
 . ./mgi-common
index 6070b8aba8b94510017d689e3e433aba6289f70d..7e3fb201e4451245b570dc744e4b97d84663a628 100755 (executable)
@@ -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
index 1bbaef7ac578d4cb1166d93dc82d21b8ada13aed..4e76a6930c981a5e471cdfa4c04ce6fb818b777d 100755 (executable)
@@ -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
 
index 0d8c792f24341c1f40fdb6b0df5b34d1c8a2f7db..8b2c21c575ab631ec9ab37d96acd3b5d24083ce2 100755 (executable)
@@ -29,7 +29,7 @@ usage () { cat <<END
 END
 }
 
-set -e
+set -e -o posix
 
 publish=false
 
index 9774350bdf13637bad3c634e14de95898856d853..e0e347de44bf8e0be128a5eb95d6c34b74f991fb 100755 (executable)
@@ -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
index f1d24cd3317114147fa539925e62eff9a4d66d01..3ff7ffae71cbcdcdb49bb1ef532dfab0f35487c1 100755 (executable)
@@ -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"
 
index 8b005f1ebfd60de4b0d4cd933bbea244e2dbc80d..1c3ecb288a9490ec38c5f930c73c15419c04478e 100755 (executable)
@@ -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
index 37ab4be4ff4028d3784467a89c76ded344f4b1b1..bd9aa4a4dfe97ed2eb66315a0f994fe05178779a 100755 (executable)
@@ -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
index 41ec73454658f715283fb5ac1d2cdaea0698b208..b2dd601fb052b2126167f50ee8818229e4172fab 100755 (executable)
@@ -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`
index 9383d720f8bd95d6fbc3299707286eb0a029dd46..168a46c38a09e7a6e5a97787e0198da88bc61cf1 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -e -o posix
 
 usage() {
     cat >&2 <<EOF
index da3c0f8cf30f58f2b7fdd5b67396ef90817f5142..d113927d9cde6de25811455b1fced7afe3072dbf 100755 (executable)
@@ -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
 
index 0a69915bb9c2b98756c3226fa25bfc0c13626526..e58ba68e3c8b47d3dfc28d6a303ae144c5126708 100755 (executable)
@@ -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