Skip to contentSkip to conversation

Fix some bashisms

PATCH Mike Frysinger 3 participants 4 messages Jun 23, 2009 – Jul 6, 2009 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Review

Quoted 4 lines · On Sunday 31 May 2009 17:27:51 Jiri Palecek > wrote:
(quoted diff) +3 -1
-echo -e "Completed running Default LTP\n\n"
+echo "Completed running Default LTP"
+echo
+echo

use printf, not bloat the file with echos

Review

Quoted 3 lines
(quoted diff) +1 -1
-echo "Distro type is: $tvar \n"
+echo "Distro type is: $tvar"

these are not equivalent

Quoted 14 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
@@ -62,7 +62,6 @@ chk_ifexists()
 # 				- non-zero on failure.
 cleanup()
 {
-	popd
 	# remove all the temporary files created by this test.
 	tst_resm TINFO "CLEAN: removing \"$LTPTMP\""
 	rm -fr "$LTPTMP"
@@ -90,7 +89,6 @@ init()
 	# create the temporary directory used by this testcase
 	LTPTMP=`mktemp -d -t $$.XXXXXX` || tst_resm TBROK "Unable to create

temporary directory with: mktemp -d $$.XXXXXX" trap "cleanup" 0

testcases/commands/unzip/unzip_tests.sh

Quoted 4 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
-	pushd "$LTPTMP"
 
 	# check if commands tst_*, unzip, awk, etc exists.
 	chk_ifexists INIT tst_resm  || return $RC

umm, you remove the push/popd, but dont replace it with proper cd statements ? i'm guessing you didnt test this change.

testcases/kernel/containers/netns/delchild.sh

Quoted 4 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    kill -9 $sshpid $pid > /dev/null 2>&1
+    kill -s KILL $sshpid $pid > /dev/null 2>&1

this isnt a bashism, this is a crappy kill implementation

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines

for tttype in ls /dev/tty*
do

testcases/kernel/containers/netns/delchild.sh +2 -2
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}
...
 for tttype in `ls /dev/tty*`
 do
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}

using the greedy expansion (##) doesnt make much sense. really should be #.

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines
testcases/kernel/containers/netns/delchild.sh +4 -4
-    let step_errors="$step_errors + 1"
+    step_errors=$(($step_errors + 1))
-        let i="$i + 1"
+        i=$(($i + 1))
-            let k="$k + 1"
+            k=$(($k + 1))
-        let j="$j + 1"
+        j=$(($j + 1))
.....

this syntax sucks. please use something like:
: $(( step_errors += 1))

testcases/kernel/containers/netns/delchild.sh

Quoted 2 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    echo $"fs_inod on $TCtmp finished."
+    echo "fs_inod on $TCtmp finished."

these are not equivalent, but i doubt this shell script is using the bash gettext function in the first place, so it's fine
-mike

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw

New Changes to Mikeś comments ?

Regards--
Subrata

Quoted 71 lines · Mike Frysinger

Review

Quoted 4 lines · On Sunday 31 May 2009 17:27:51 Jiri Palecek > wrote:
(quoted diff) +3 -1
-echo -e "Completed running Default LTP\n\n"
+echo "Completed running Default LTP"
+echo
+echo

use printf, not bloat the file with echos

Review

Quoted 3 lines
(quoted diff) +1 -1
-echo "Distro type is: $tvar \n"
+echo "Distro type is: $tvar"

these are not equivalent

Quoted 14 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
@@ -62,7 +62,6 @@ chk_ifexists()
 # 				- non-zero on failure.
 cleanup()
 {
-	popd
 	# remove all the temporary files created by this test.
 	tst_resm TINFO "CLEAN: removing \"$LTPTMP\""
 	rm -fr "$LTPTMP"
@@ -90,7 +89,6 @@ init()
 	# create the temporary directory used by this testcase
 	LTPTMP=`mktemp -d -t $$.XXXXXX` || tst_resm TBROK "Unable to create

temporary directory with: mktemp -d $$.XXXXXX" trap "cleanup" 0

testcases/commands/unzip/unzip_tests.sh

Quoted 4 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
-	pushd "$LTPTMP"
 
 	# check if commands tst_*, unzip, awk, etc exists.
 	chk_ifexists INIT tst_resm  || return $RC

umm, you remove the push/popd, but dont replace it with proper cd statements ? i'm guessing you didnt test this change.

testcases/kernel/containers/netns/delchild.sh

Quoted 4 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    kill -9 $sshpid $pid > /dev/null 2>&1
+    kill -s KILL $sshpid $pid > /dev/null 2>&1

this isnt a bashism, this is a crappy kill implementation

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines

for tttype in ls /dev/tty*
do

testcases/kernel/containers/netns/delchild.sh +2 -2
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}
...
 for tttype in `ls /dev/tty*`
 do
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}

using the greedy expansion (##) doesnt make much sense. really should be #.

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines
testcases/kernel/containers/netns/delchild.sh +4 -4
-    let step_errors="$step_errors + 1"
+    step_errors=$(($step_errors + 1))
-        let i="$i + 1"
+        i=$(($i + 1))
-            let k="$k + 1"
+            k=$(($k + 1))
-        let j="$j + 1"
+        j=$(($j + 1))
.....

this syntax sucks. please use something like:
: $(( step_errors += 1))

testcases/kernel/containers/netns/delchild.sh

Quoted 2 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    echo $"fs_inod on $TCtmp finished."
+    echo "fs_inod on $TCtmp finished."
Quoted 8 lines

these are not equivalent, but i doubt this shell script is using the bash gettext function in the first place, so it's fine
-mike
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 1 line · Subrata Modak

New Changes to Mikeś comments ?

Ping.

Quoted 86 lines

Regards--
Subrata

Quoted 71 lines · Mike Frysinger

Review

Quoted 4 lines · On Sunday 31 May 2009 17:27:51 Jiri Palecek > wrote:
(quoted diff) +3 -1
-echo -e "Completed running Default LTP\n\n"
+echo "Completed running Default LTP"
+echo
+echo

use printf, not bloat the file with echos

Review

Quoted 3 lines
(quoted diff) +1 -1
-echo "Distro type is: $tvar \n"
+echo "Distro type is: $tvar"

these are not equivalent

Quoted 14 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
@@ -62,7 +62,6 @@ chk_ifexists()
 # 				- non-zero on failure.
 cleanup()
 {
-	popd
 	# remove all the temporary files created by this test.
 	tst_resm TINFO "CLEAN: removing \"$LTPTMP\""
 	rm -fr "$LTPTMP"
@@ -90,7 +89,6 @@ init()
 	# create the temporary directory used by this testcase
 	LTPTMP=`mktemp -d -t $$.XXXXXX` || tst_resm TBROK "Unable to create

temporary directory with: mktemp -d $$.XXXXXX" trap "cleanup" 0

testcases/commands/unzip/unzip_tests.sh

Quoted 4 lines
testcases/commands/unzip/unzip_tests.sh +0 -1
-	pushd "$LTPTMP"
 
 	# check if commands tst_*, unzip, awk, etc exists.
 	chk_ifexists INIT tst_resm  || return $RC

umm, you remove the push/popd, but dont replace it with proper cd statements ? i'm guessing you didnt test this change.

testcases/kernel/containers/netns/delchild.sh

Quoted 4 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    kill -9 $sshpid $pid > /dev/null 2>&1
+    kill -s KILL $sshpid $pid > /dev/null 2>&1

this isnt a bashism, this is a crappy kill implementation

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines

for tttype in ls /dev/tty*
do

testcases/kernel/containers/netns/delchild.sh +2 -2
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}
...
 for tttype in `ls /dev/tty*`
 do
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}

using the greedy expansion (##) doesnt make much sense. really should be #.

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines
testcases/kernel/containers/netns/delchild.sh +4 -4
-    let step_errors="$step_errors + 1"
+    step_errors=$(($step_errors + 1))
-        let i="$i + 1"
+        i=$(($i + 1))
-            let k="$k + 1"
+            k=$(($k + 1))
-        let j="$j + 1"
+        j=$(($j + 1))
.....

this syntax sucks. please use something like:
: $(( step_errors += 1))

testcases/kernel/containers/netns/delchild.sh

Quoted 2 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    echo $"fs_inod on $TCtmp finished."
+    echo "fs_inod on $TCtmp finished."
Quoted 8 lines

these are not equivalent, but i doubt this shell script is using the bash gettext function in the first place, so it's fine
-mike
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Quoted 5 lines

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw
Quoted 4 lines · On Tuesday 30 June 2009 09:41:10 Subrata Modak wrote:
Quoted 1 line · Subrata Modak

New Changes to Mikeś comments ?

Ping.

Ok, I finally got time to look into this. I'll send a separate patch which reflects the comments.

Quoted 22 lines
Quoted 22 lines

Regards--
Subrata

Quoted 17 lines · Mike Frysinger
Quoted 16 lines · On Sunday 31 May 2009 17:27:51 Jiri Palecek > wrote:
testcases/commands/unzip/unzip_tests.sh +0 -1
@@ -62,7 +62,6 @@ chk_ifexists()
 # 				- non-zero on failure.
 cleanup()
 {
-	popd
 	# remove all the temporary files created by this test.
 	tst_resm TINFO "CLEAN: removing \"$LTPTMP\""
 	rm -fr "$LTPTMP"
@@ -90,7 +89,6 @@ init()
 	# create the temporary directory used by this testcase
 	LTPTMP=`mktemp -d -t $$.XXXXXX` || tst_resm TBROK "Unable to create

temporary directory with: mktemp -d $$.XXXXXX" trap "cleanup" 0

testcases/commands/unzip/unzip_tests.sh +0 -1
-	pushd "$LTPTMP"
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

testcases/commands/unzip/unzip_tests.sh

Quoted 2 lines
testcases/commands/unzip/unzip_tests.sh +0 -0
 	# check if commands tst_*, unzip, awk, etc exists.
 	chk_ifexists INIT tst_resm  || return $RC

umm, you remove the push/popd, but dont replace it with proper cd statements ? i'm guessing you didnt test this change.

Oh yes, I did, but I tested it with other changes which rendered the pushd/popd unnecessary. You're right this wouldn't work.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

testcases/kernel/containers/netns/delchild.sh

Quoted 4 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    kill -9 $sshpid $pid > /dev/null 2>&1
+    kill -s KILL $sshpid $pid > /dev/null 2>&1

this isnt a bashism, this is a crappy kill implementation

Formally speaking, this is an XSI extension to POSIX. I don't think this "-9" is any better than "-s KILL", so I won't change this.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

testcases/kernel/containers/netns/delchild.sh

Quoted 9 lines

for tttype in ls /dev/tty*
do

testcases/kernel/containers/netns/delchild.sh +2 -2
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}
...
 for tttype in `ls /dev/tty*`
 do
-device_no=${tttype:8}
+device_no=${tttype##/dev/tty}

using the greedy expansion (##) doesnt make much sense. really should be #.

Quoted 9 lines
testcases/kernel/containers/netns/delchild.sh +4 -4
-    let step_errors="$step_errors + 1"
+    step_errors=$(($step_errors + 1))
-        let i="$i + 1"
+        i=$(($i + 1))
-            let k="$k + 1"
+            k=$(($k + 1))
-        let j="$j + 1"
+        j=$(($j + 1))
.....
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

this syntax sucks. please use something like:
: $(( step_errors += 1))

If it hurts your aesthetic sense ... ok.

Quoted 14 lines
Quoted 14 lines
Quoted 12 lines

testcases/kernel/containers/netns/delchild.sh

Quoted 3 lines
testcases/kernel/containers/netns/delchild.sh +1 -1
-    echo $"fs_inod on $TCtmp finished."
+    echo "fs_inod on $TCtmp finished."

these are not equivalent, but i doubt this shell script is using the bash gettext function in the first place, so it's fine
-mike
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Quoted 7 lines
Quoted 5 lines

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list