diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-02-05 12:14:03 +0200 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-02-05 17:12:12 +0200 |
commit | 321e17fb8023c5f5f4222c456d9f924c25067949 (patch) | |
tree | d31e0ea791eb240f4da29ecabda540c5a9289d61 | |
parent | 264e0d13eab265c4bfe0a5f73be317d15608f542 (diff) | |
download | aiaiai-321e17fb8023c5f5f4222c456d9f924c25067949.tar.gz |
Switch to dash when possible
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>
-rwxr-xr-x | aiaiai-checker | 7 | ||||
-rwxr-xr-x | aiaiai-diff-log | 7 | ||||
-rwxr-xr-x | aiaiai-make-kernel | 7 | ||||
-rwxr-xr-x | aiaiai-match-keywords | 8 | ||||
-rw-r--r-- | aiaiai-sh-functions | 12 | ||||
-rwxr-xr-x | aiaiai-test-bisectability | 7 | ||||
-rwxr-xr-x | aiaiai-test-patchset | 7 | ||||
-rwxr-xr-x | email/aiaiai-email-dispatcher | 7 | ||||
-rwxr-xr-x | email/aiaiai-email-dispatcher-helper | 8 | ||||
-rwxr-xr-x | email/aiaiai-email-lda | 7 | ||||
-rwxr-xr-x | email/aiaiai-email-test-patchset | 7 | ||||
-rwxr-xr-x | jenkins/aiaiai-jenkins-test-patchset | 8 |
12 files changed, 92 insertions, 0 deletions
diff --git a/aiaiai-checker b/aiaiai-checker index 929423a..5ca71c3 100755 --- a/aiaiai-checker +++ b/aiaiai-checker @@ -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 diff --git a/aiaiai-diff-log b/aiaiai-diff-log index cc4a63c..55c2136 100755 --- a/aiaiai-diff-log +++ b/aiaiai-diff-log @@ -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 diff --git a/aiaiai-make-kernel b/aiaiai-make-kernel index bba9957..5ce11aa 100755 --- a/aiaiai-make-kernel +++ b/aiaiai-make-kernel @@ -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 diff --git a/aiaiai-match-keywords b/aiaiai-match-keywords index 4488853..701f459 100755 --- a/aiaiai-match-keywords +++ b/aiaiai-match-keywords @@ -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 diff --git a/aiaiai-sh-functions b/aiaiai-sh-functions index 0eb6840..abbd0f4 100644 --- a/aiaiai-sh-functions +++ b/aiaiai-sh-functions @@ -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() diff --git a/aiaiai-test-bisectability b/aiaiai-test-bisectability index bc46f9b..121312a 100755 --- a/aiaiai-test-bisectability +++ b/aiaiai-test-bisectability @@ -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 diff --git a/aiaiai-test-patchset b/aiaiai-test-patchset index 58287cc..b231d30 100755 --- a/aiaiai-test-patchset +++ b/aiaiai-test-patchset @@ -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 diff --git a/email/aiaiai-email-dispatcher b/email/aiaiai-email-dispatcher index 4e303d9..9fa7847 100755 --- a/email/aiaiai-email-dispatcher +++ b/email/aiaiai-email-dispatcher @@ -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 diff --git a/email/aiaiai-email-dispatcher-helper b/email/aiaiai-email-dispatcher-helper index ab65849..91722b0 100755 --- a/email/aiaiai-email-dispatcher-helper +++ b/email/aiaiai-email-dispatcher-helper @@ -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 diff --git a/email/aiaiai-email-lda b/email/aiaiai-email-lda index de2cfb0..02a4a6b 100755 --- a/email/aiaiai-email-lda +++ b/email/aiaiai-email-lda @@ -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 diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset index 77ead41..97083b2 100755 --- a/email/aiaiai-email-test-patchset +++ b/email/aiaiai-email-test-patchset @@ -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 diff --git a/jenkins/aiaiai-jenkins-test-patchset b/jenkins/aiaiai-jenkins-test-patchset index 721cff9..bc5c948 100755 --- a/jenkins/aiaiai-jenkins-test-patchset +++ b/jenkins/aiaiai-jenkins-test-patchset @@ -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 |