]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
Switch to dash when possible
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 5 Feb 2014 10:14:03 +0000 (12:14 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 5 Feb 2014 15:12:12 +0000 (17:12 +0200)
Aiaiai is written in a portable manner, meaning that it does not use Bash
features and should work with different shells, like dash and ksh. Actually,
dash is a nice, small, and fast shell implementing only POSIX feature (or may
be mostly), and it is good to use it when it is available. This will ensure
that we do not accidentally break protability.

This patch adds a small code snippet to each script which will check if dash is
installed in the system, and if it is, "re-start" with dash.

People hacking on Aiaiai are encouradge to install the 'dash' package on their
systems.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
12 files changed:
aiaiai-checker
aiaiai-diff-log
aiaiai-make-kernel
aiaiai-match-keywords
aiaiai-sh-functions
aiaiai-test-bisectability
aiaiai-test-patchset
email/aiaiai-email-dispatcher
email/aiaiai-email-dispatcher-helper
email/aiaiai-email-lda
email/aiaiai-email-test-patchset
jenkins/aiaiai-jenkins-test-patchset

index 929423ad175c445ba2df80f87ea77c7cf54789fb..5ca71c3a95c09f9760206766e5a176bddcae588f 100755 (executable)
@@ -15,6 +15,13 @@ PATH="$srcdir:$srcdir/external/libshell:$srcdir/external:$PATH"
 
 PROG="${0##*/}"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index cc4a63ce965c3f418504106121e3eac72759a4f4..55c2136fecf831f4aeefb0ef06eab51bd626348c 100755 (executable)
@@ -17,6 +17,13 @@ PATH="$srcdir:$srcdir/external/libshell:$srcdir/external:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
         cat <<-EOF
index bba99578191f2cedb913b114bd0ea7d3076b15d5..5ce11aa070038dd5bd40f879c1d807923730bed7 100755 (executable)
@@ -16,6 +16,13 @@ export PATH="$srcdir:$srcdir/external/libshell:$srcdir/external:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 448885352c5c5ba9f09ede20fd7ff77e396e114a..701f4594b21ede51188aeec82b66656881b5f355 100755 (executable)
@@ -10,10 +10,18 @@ PATH="$srcdir:$srcdir/external/libshell:$PATH"
 . shell-error
 . shell-args
 . shell-quote
+. aiaiai-sh-functions
 
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 0eb68409522578431b926932b40d596074196c7e..abbd0f4524e256fce51b37fcbdaeca6c1d55fb64 100644 (file)
@@ -28,6 +28,18 @@ print_separator()
        echo
 }
 
+# Check if dash is available and we are not running in dash
+can_switch_to_dash()
+{
+       if command -v "dash" >/dev/null 2>&1; then
+               if [ -n "${BASH_VERSION:-}" ]; then
+                       return 0
+               fi
+       fi
+
+       return 1
+}
+
 # Die if a program is not in PATH
 # Usage: program_required <program_name>
 program_required()
index bc46f9b595cc0f734570fd1b6c58c42d333a407c..121312a7ba2bbdfc28e0a72ffcbac66130479f07 100755 (executable)
@@ -15,6 +15,13 @@ PATH="$srcdir:$srcdir/external/libshell:$srcdir/external:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 58287cc590a073a33d3fc8e5bd630e9dd3c34e85..b231d30514d4acd9a6ca9c61c21cc6a1922f1a6d 100755 (executable)
@@ -15,6 +15,13 @@ PATH="$srcdir:$srcdir/external/libshell:$srcdir/external:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 4e303d980504f24b8241c3c66c2895b4218875c8..9fa784737fd22acb63ff6f62315c621e44359aeb 100755 (executable)
@@ -15,6 +15,13 @@ PATH="$srcdir:$srcdir/email:$srcdir/external/libshell:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index ab65849c2bfb5f52ebcf8178289c6b9e8a0fc028..91722b0e871570cf35c12b0628f25cfc532d36fa 100755 (executable)
@@ -9,10 +9,18 @@ PATH="$srcdir:$srcdir/email:$srcdir/external/libshell:$PATH"
 
 . shell-error
 . shell-signal
+. aiaiai-sh-functions
 
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index de2cfb023c0fe98ba843338dec3624a5de383826..02a4a6b184213191f9f11952efdfa66e55df8e87 100755 (executable)
@@ -16,6 +16,13 @@ PATH="$srcdir:$srcdir/email:$srcdir/external/libshell:$PATH"
 PROG="${0##*/}"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 77ead41b6c07ea424fcbe634644311d3309be2f5..97083b2cd9e3012c9fd02f1b16b6b6e02bffe0cc 100755 (executable)
@@ -16,6 +16,13 @@ PATH="$srcdir:$srcdir/email:$srcdir/external/libshell:$PATH"
 PROG="${0##*/}"
 export message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF
index 721cff9507dd222acca0831d5eddc30eff938e6a..bc5c948911c32dcc904a30bd2da2b5190f74838e 100755 (executable)
@@ -13,8 +13,16 @@ PATH="$srcdir/..:$srcdir/../external/libshell:$PATH"
 . shell-quote
 . aiaiai-sh-functions
 
+PROG="aiaiai-jenkins-test-patchset"
 message_time="yes"
 
+# This is a small trick to make sure the script is portable - check if 'dash'
+# is present, and if yes - use it.
+if can_switch_to_dash; then
+       exec dash -euf -- "$srcdir/$PROG" "$@"
+       exit $?
+fi
+
 show_usage()
 {
        cat <<-EOF