* Re: [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script]
2008-03-21 20:24 [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script] Jan Kiszka
@ 2008-03-22 15:54 ` Roland Stigge
2008-03-23 16:45 ` Gilles Chanteperdrix
2008-03-24 13:51 ` Gilles Chanteperdrix
2008-03-24 14:14 ` Gilles Chanteperdrix
2 siblings, 1 reply; 5+ messages in thread
From: Roland Stigge @ 2008-03-22 15:54 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Xenomai-core
[-- Attachment #1: Type: text/plain, Size: 206 bytes --]
Jan Kiszka wrote:
> Maybe someone with idle cycles left could have a look at this.
Idle? Preempted, at most!
Attached is what I will apply to the Debian version. Feel free to do as
well...
bye,
Roland
[-- Attachment #2: xenomai.patch --]
[-- Type: text/x-diff, Size: 1025 bytes --]
diff -u scripts.orig/xeno-info scripts/xeno-info
--- scripts.orig/xeno-info 2007-12-09 11:46:37.000000000 +0100
+++ scripts/xeno-info 2008-03-22 16:50:19.000000000 +0100
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
#
# This file has been lifted 'as is' from linux/scripts/ver_linux.
# Adapted to be run also under the BusyBox. If you want to test it under the BusyBox use
diff -u scripts.orig/xeno-load.in scripts/xeno-load.in
--- scripts.orig/xeno-load.in 2007-12-09 11:46:37.000000000 +0100
+++ scripts/xeno-load.in 2008-03-22 16:50:57.000000000 +0100
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
# Xenomai application loader script.
# (Processes the .runinfo files)
# June 2004, <rpm@xenomai.org>
diff -u scripts.orig/xeno-test.in scripts/xeno-test.in
--- scripts.orig/xeno-test.in 2008-02-20 18:18:46.000000000 +0100
+++ scripts/xeno-test.in 2008-03-22 16:50:32.000000000 +0100
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
# Adapted to be run also under the BusyBox.
# If you want to test it this way, do: sh xeno-test
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script]
2008-03-22 15:54 ` Roland Stigge
@ 2008-03-23 16:45 ` Gilles Chanteperdrix
0 siblings, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2008-03-23 16:45 UTC (permalink / raw)
To: Roland Stigge; +Cc: Jan Kiszka, Xenomai-core
Roland Stigge wrote:
> Jan Kiszka wrote:
> > Maybe someone with idle cycles left could have a look at this.
>
> Idle? Preempted, at most!
>
> Attached is what I will apply to the Debian version. Feel free to do as
> well...
IMO, making the scripts sh compliant is worth the trouble: we do not
know what shell the users will use, this would give us maximum
compatibility.
--
Gilles.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script]
2008-03-21 20:24 [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script] Jan Kiszka
2008-03-22 15:54 ` Roland Stigge
@ 2008-03-24 13:51 ` Gilles Chanteperdrix
2008-03-24 14:14 ` Gilles Chanteperdrix
2 siblings, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2008-03-24 13:51 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Xenomai-core
[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 145 bytes --]
Jan Kiszka wrote:
> Maybe someone with idle cycles left could have a look at this.
Ok. Here comes an (untested) patch.
--
Gilles.
[-- Attachment #2: xeno-sh-scripts.diff --]
[-- Type: text/plain, Size: 4291 bytes --]
Index: scripts/xeno-info
===================================================================
--- scripts/xeno-info (revision 3623)
+++ scripts/xeno-info (working copy)
@@ -74,7 +74,7 @@ ldd -v > /dev/null 2>&1 && ldd -v || ldd
'NR==1{print "Dynamic linker (ldd) ", $NF}'
fi
-ls -l /usr/lib/lib{g,stdc}++.so 2>/dev/null | awk -F. \
+ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \
'{print "Linux C++ Library " $4"."$5"."$6}'
if test 0 -eq $withBusybox ; then
Index: scripts/xeno-load.in
===================================================================
--- scripts/xeno-load.in (revision 3623)
+++ scripts/xeno-load.in (working copy)
@@ -127,7 +127,7 @@ children_pids=""
cleanup () {
if test \! "x$children_pids" = x; then
- $sudo kill -SIGINT $children_pids >& /dev/null
+ $sudo kill -SIGINT $children_pids > /dev/null 2>&1
children_pids=""
sleep 1
fi
Index: scripts/xeno-test.in
===================================================================
--- scripts/xeno-test.in (revision 3623)
+++ scripts/xeno-test.in (working copy)
@@ -60,9 +60,9 @@ pidFile=/var/lock/`basename $0.$$`.pids
checkUtilities() {
# Check for needed helper utilities
- local neededApplets="awk basename cut date dd dirname egrep grep head
+ neededApplets="awk basename cut date dd dirname egrep grep head
kill md5sum mount sleep test top uname zcat"
- local foundAll=1
+ foundAll=1
for _j in $neededApplets
do
if test -z "`which $_j`"; then
@@ -74,11 +74,17 @@ checkUtilities() {
echo "Please build busybox's ash with support for getopts"
foundAll=0
fi
- if test $foundAll -eq 0 ; then exit 3 ; fi
+ if test $foundAll -eq 0 ; then
+ needApplets=""
+ foundAll=""
+ exit 3
+ fi
+ needApplets=""
+ foundAll=""
}
checkHelpers() {
- local foundAll=1
+ foundAll=1
if test -z "`which script`" -a -n "$logging"; then
echo "You will not be able to log (-L option) as script is missing"
foundAll=0
@@ -91,7 +97,11 @@ checkHelpers() {
echo "You will not be able to upload (-U option) as curl is missing"
foundAll=0
fi
- if test $foundAll -eq 0 ; then exit 3 ; fi
+ if test $foundAll -eq 0 ; then
+ foundAll=""
+ exit 3
+ fi
+ foundAll=""
}
loudly() {
@@ -111,7 +121,7 @@ dd_jobs=
mkload() { dd if=$device of=/dev/null $* & }
generate_loads() {
- local jobsct=$1;
+ jobsct=$1;
# if test -z "$1"; then echo Skipping generate_loads; return; fi
shift 1
if test 0 -eq $withBusybox ; then
@@ -120,13 +130,14 @@ generate_loads() {
trap cleanup_load EXIT # under all exit conditions
fi
while test $jobsct -ge 1; do
- jobsct=$((jobsct-1));
+ jobsct=`expr $jobsct - 1`;
mkload
dd_jobs="$dd_jobs $!" ;
done
echo dd workload started, pids $dd_jobs stored in $pidFile
echo $dd_jobs > $pidFile
+ jobsct=""
}
cleanup_load() {
@@ -159,7 +170,7 @@ boxinfo() { # static info, show once
loudly md5sum /proc/cpuinfo '# cpuinfo fingerprint'
# how much of the config do we want ?
- local filter=" grep -E '$whatconf'"
+ filter=" grep -E '$whatconf'"
[ "$verbose" = 1 ] && filter=
if test -f /proc/config.gz; then # get the config
loudly zcat /proc/config.gz | $filter
@@ -170,6 +181,7 @@ boxinfo() { # static info, show once
[ -d /proc/adeos ] && for f in /proc/adeos/*; do loudly cat $f; done
[ -d /proc/ipipe ] && for f in /proc/ipipe/*; do loudly cat $f; done
+ filter=""
}
boxstatus() { # get dynamic status
@@ -274,7 +286,7 @@ verbose=
dateargs='+%y%m%d.%H%M%S'
sendit() {
- local file=$1
+ file=$1
if test "$sendit" = 'm' ; then
echo "mailing $file to $email"
if test -n "$file" ; then
@@ -290,6 +302,7 @@ sendit() {
else
echo "sendit unsupported option '$sendit'"
fi
+ file=""
}
handle_options() { # called for XENOTEST_OPTS, ARGV
@@ -379,7 +392,7 @@ if test "$logging" != "" ; then
# restart inside a script invocation, passing appropriate args
script -c "`dirname $0`/xeno-test $loadpass $latpass $*" $wfile
res="$?"
- if test "$res" == "0" ; then
+ if test "$res" = "0" ; then
sendit $wfile
fi
else
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script]
2008-03-21 20:24 [Xenomai-core] [Fwd: Bug#471871: xenomai-runtime: bashism in /bin/sh script] Jan Kiszka
2008-03-22 15:54 ` Roland Stigge
2008-03-24 13:51 ` Gilles Chanteperdrix
@ 2008-03-24 14:14 ` Gilles Chanteperdrix
2 siblings, 0 replies; 5+ messages in thread
From: Gilles Chanteperdrix @ 2008-03-24 14:14 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Xenomai-core
[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 240 bytes --]
Jan Kiszka wrote:
> Maybe someone with idle cycles left could have a look at this.
We do not need expr actually, $(()) also works with sh, but can not make
reference to a variable without a $, hence the new patch.
--
Gilles.
[-- Attachment #2: xeno-sh-scripts.diff --]
[-- Type: text/plain, Size: 4286 bytes --]
Index: scripts/xeno-info
===================================================================
--- scripts/xeno-info (revision 3623)
+++ scripts/xeno-info (working copy)
@@ -74,7 +74,7 @@ ldd -v > /dev/null 2>&1 && ldd -v || ldd
'NR==1{print "Dynamic linker (ldd) ", $NF}'
fi
-ls -l /usr/lib/lib{g,stdc}++.so 2>/dev/null | awk -F. \
+ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \
'{print "Linux C++ Library " $4"."$5"."$6}'
if test 0 -eq $withBusybox ; then
Index: scripts/xeno-load.in
===================================================================
--- scripts/xeno-load.in (revision 3623)
+++ scripts/xeno-load.in (working copy)
@@ -127,7 +127,7 @@ children_pids=""
cleanup () {
if test \! "x$children_pids" = x; then
- $sudo kill -SIGINT $children_pids >& /dev/null
+ $sudo kill -SIGINT $children_pids > /dev/null 2>&1
children_pids=""
sleep 1
fi
Index: scripts/xeno-test.in
===================================================================
--- scripts/xeno-test.in (revision 3623)
+++ scripts/xeno-test.in (working copy)
@@ -60,9 +60,9 @@ pidFile=/var/lock/`basename $0.$$`.pids
checkUtilities() {
# Check for needed helper utilities
- local neededApplets="awk basename cut date dd dirname egrep grep head
+ neededApplets="awk basename cut date dd dirname egrep grep head
kill md5sum mount sleep test top uname zcat"
- local foundAll=1
+ foundAll=1
for _j in $neededApplets
do
if test -z "`which $_j`"; then
@@ -74,11 +74,17 @@ checkUtilities() {
echo "Please build busybox's ash with support for getopts"
foundAll=0
fi
- if test $foundAll -eq 0 ; then exit 3 ; fi
+ if test $foundAll -eq 0 ; then
+ needApplets=""
+ foundAll=""
+ exit 3
+ fi
+ needApplets=""
+ foundAll=""
}
checkHelpers() {
- local foundAll=1
+ foundAll=1
if test -z "`which script`" -a -n "$logging"; then
echo "You will not be able to log (-L option) as script is missing"
foundAll=0
@@ -91,7 +97,11 @@ checkHelpers() {
echo "You will not be able to upload (-U option) as curl is missing"
foundAll=0
fi
- if test $foundAll -eq 0 ; then exit 3 ; fi
+ if test $foundAll -eq 0 ; then
+ foundAll=""
+ exit 3
+ fi
+ foundAll=""
}
loudly() {
@@ -111,7 +121,7 @@ dd_jobs=
mkload() { dd if=$device of=/dev/null $* & }
generate_loads() {
- local jobsct=$1;
+ jobsct=$1;
# if test -z "$1"; then echo Skipping generate_loads; return; fi
shift 1
if test 0 -eq $withBusybox ; then
@@ -120,13 +130,14 @@ generate_loads() {
trap cleanup_load EXIT # under all exit conditions
fi
while test $jobsct -ge 1; do
- jobsct=$((jobsct-1));
+ jobsct=$(($jobsct-1));
mkload
dd_jobs="$dd_jobs $!" ;
done
echo dd workload started, pids $dd_jobs stored in $pidFile
echo $dd_jobs > $pidFile
+ jobsct=""
}
cleanup_load() {
@@ -159,7 +170,7 @@ boxinfo() { # static info, show once
loudly md5sum /proc/cpuinfo '# cpuinfo fingerprint'
# how much of the config do we want ?
- local filter=" grep -E '$whatconf'"
+ filter=" grep -E '$whatconf'"
[ "$verbose" = 1 ] && filter=
if test -f /proc/config.gz; then # get the config
loudly zcat /proc/config.gz | $filter
@@ -170,6 +181,7 @@ boxinfo() { # static info, show once
[ -d /proc/adeos ] && for f in /proc/adeos/*; do loudly cat $f; done
[ -d /proc/ipipe ] && for f in /proc/ipipe/*; do loudly cat $f; done
+ filter=""
}
boxstatus() { # get dynamic status
@@ -274,7 +286,7 @@ verbose=
dateargs='+%y%m%d.%H%M%S'
sendit() {
- local file=$1
+ file=$1
if test "$sendit" = 'm' ; then
echo "mailing $file to $email"
if test -n "$file" ; then
@@ -290,6 +302,7 @@ sendit() {
else
echo "sendit unsupported option '$sendit'"
fi
+ file=""
}
handle_options() { # called for XENOTEST_OPTS, ARGV
@@ -379,7 +392,7 @@ if test "$logging" != "" ; then
# restart inside a script invocation, passing appropriate args
script -c "`dirname $0`/xeno-test $loadpass $latpass $*" $wfile
res="$?"
- if test "$res" == "0" ; then
+ if test "$res" = "0" ; then
sendit $wfile
fi
else
^ permalink raw reply [flat|nested] 5+ messages in thread