Skip to contentSkip to conversation

shell: fix bashisms: s/&>/>$1 2>&1/

PATCH Superseded Petr Vorel 3 participants 7 messages Nov 25, 2016 – Nov 28, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/4 shell: fix bashisms: s/&>/>$1 2>&1/

---
 ltpmenu                                                        |  2 +-
 runltplite.sh                                                  |  2 +-
 testcases/commands/cron/cron_neg_tests.sh                      |  4 ++--
 testcases/commands/cron/cron_pos_tests.sh                      |  6 +++---
 .../ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh | 10 +++++-----
 .../ext4-inode-version/ext4_inode_version_test.sh              |  6 +++---
 .../ext4-journal-checksum/ext4_journal_checksum.sh             |  6 +++---
 .../ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh          |  6 +++---
 .../ext4-persist-prealloc/ext4_persist_prealloc_test.sh        |  4 ++--
 .../ext4-subdir-limit/ext4_subdir_limit_test.sh                |  6 +++---
 .../ext4-uninit-groups/ext4_uninit_groups_test.sh              |  8 ++++----
 testcases/kernel/fs/iso9660/isofs.sh                           |  2 +-
 .../kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh      |  4 ++--
 testcases/kernel/numa/numa01.sh                                |  4 ++--
 testcases/kernel/security/mmc_security/ask_password.sh         |  4 ++--
 testcases/kernel/security/mmc_security/assign_password.sh      |  4 ++--
 testcases/lib/daemonlib.sh                                     |  8 ++++----
 testcases/open_posix_testsuite/stress/threads/helper.c         |  2 +-
 18 files changed, 44 insertions(+), 44 deletions(-)
ltpmenu +1 -1
index 6a2338b..38d38c0 100755
@@ -112,7 +112,7 @@ compile_ltp()
         0) \
             for cmd in cc make lex ;
             do \
-                which $cmd &>/tmp/runltp.err.$$ ;
+                which $cmd >/tmp/runltp.err.$$ 2>&1 ;
                 if [ $? -ne 0 ] ;
                     then \
                         display_info_msg "Compiling LTP testsuite" \
runltplite.sh +1 -1
index 00a1078..9313649 100755
@@ -295,7 +295,7 @@ main()
     }
 
     # check for required users and groups
-    ${LTPROOT}/IDcheck.sh &>/dev/null || \
+    ${LTPROOT}/IDcheck.sh >/dev/null 2>&1 || \
     {
         echo "WARNING: required users and groups not present"
         echo "WARNING: some test cases may fail"
testcases/commands/cron/cron_neg_tests.sh +2 -2
index 27f2137..9c3d6f6 100755
@@ -87,7 +87,7 @@ echo setuid test
 echo
 
 tmpscript=cron_neg01_test
-rm -rf $tmpscript.out &> /dev/null
+rm -rf $tmpscript.out >/dev/null 2>&1
 
 
 cat > /tmp/$tmpscript << EOF
@@ -127,7 +127,7 @@ else
 fi
 echo
 
-rm /tmp/$tmpscript* &> /dev/null
+rm /tmp/$tmpscript* >/dev/null 2>&1
 crontab -r
 
 # Restore crontab
testcases/commands/cron/cron_pos_tests.sh +3 -3
index 2dc4ecc..ece114c 100755
@@ -22,10 +22,10 @@ if [ $iam = "root" ]; then
 		exit 1
 	fi
 
-	mv $CRON_ALLOW $CRON_ALLOW.old &> /dev/null
+	mv $CRON_ALLOW $CRON_ALLOW.old >/dev/null 2>&1
 	su $1 -c "$0 $*"
         RC=$?
-	mv $CRON_ALLOW.old $CRON_ALLOW &> /dev/null
+	mv $CRON_ALLOW.old $CRON_ALLOW >/dev/null 2>&1
 	exit $RC
 fi
 
@@ -53,7 +53,7 @@ fi
 
 # 1. Add new job
 
-rm -rf /tmp/crontest &> /dev/null
+rm -rf /tmp/crontest >/dev/null 2>&1
 mkdir -p /tmp/crontest
 
 cat > /tmp/crontest/testjob_cron01 << EOF
testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh +5 -5
index 16f621f..a5215bd 100755
@@ -28,7 +28,7 @@ export TST_TOTAL=17
 # Case 17: mount ext4 partition to ext3
 ext4_test_remount()
 {
-	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -60,7 +60,7 @@ ext4_test_remount()
 	fi
 	umount mnt_point
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
@@ -78,13 +78,13 @@ ext4_test_delalloc_mballoc()
 {
 	tst_resm TINFO "isDelalloc: $1, isDirectIO: $2, Blocksize: $3, isAuto_da_alloc: $4"
 
-	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -105,7 +105,7 @@ ext4_test_delalloc_mballoc()
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh +3 -3
index ac8f021..ef02cc0 100755
@@ -33,13 +33,13 @@ ext4_test_128_inode_version()
 {
 	tst_resm TINFO "Test inode version is 32 bits with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o i_version $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -83,7 +83,7 @@ ext4_test_128_inode_version()
 # $1: file operation
 test_inode_version()
 {
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh +3 -3
index 87eb90b..2f357d8 100755
@@ -55,13 +55,13 @@ ext4_test_journal_checksum()
 		"journal_checksum: $checksum, " \
 		"journal_async_commit: $async_commit, barrier: $5"
 
-	mkfs.ext4 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o data=$1,commit=$2,$3,$4,barrier=$5 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -82,7 +82,7 @@ ext4_test_journal_checksum()
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh +3 -3
index ec1c6a3..c6ff7c2 100755
@@ -33,13 +33,13 @@ ext4_test_sec_timestamps()
 {
 	tst_resm TINFO "Test timestamps with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -74,7 +74,7 @@ ext4_test_nsec_timestamps()
 {
 	tst_resm TINFO "Test timestamps with 256 inode size"
 
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh +2 -2
index e2b81a2..2a4b699 100755
@@ -32,7 +32,7 @@ export TST_TOTAL=2
 # $1: 1024 or 4096
 ext4_test_persist_prealloc()
 {
-	mkfs.ext4 -I 256 -b $1 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $1 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -72,7 +72,7 @@ ext4_test_persist_prealloc()
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh +3 -3
index 3162d67..5cc0523 100755
@@ -59,14 +59,14 @@ ext4_run_case()
 	# only mkfs if block size has been changed,
 	# or previous case failed
 	if [ $prev_result -ne $PASS -o $4 -ne $prev_block_size ]; then
-		mkfs.ext4 -b $4 -I 256 $EXT4_DEV &> /dev/null
+		mkfs.ext4 -b $4 -I 256 $EXT4_DEV >/dev/null 2>&1
 		if [ $? -ne 0 ]; then
 			tst_resm TFAIL "failed to create ext4 filesystem"
 			return
 		fi
 		prev_block_size=$4
 
-		tune2fs -O extents $EXT4_DEV &> /dev/null
+		tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 	fi
 
 	prev_result=$FAIL
@@ -113,7 +113,7 @@ ext4_run_case()
 	fi
 
 	# run fsck to make sure the filesystem has no errors
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck: the filesystem has errors"
 		return
testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh +4 -4
index 4db846a..1b0e00b 100755
@@ -66,7 +66,7 @@ ext4_test_uninit_groups()
 {
 	echo "Test $TST_COUNT" >> ext4_uninit_groups_result.txt
 
-	mkfs.ext4 -I 256 -m 0 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -m 0 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -78,10 +78,10 @@ ext4_test_uninit_groups()
 		flag=$3
 	fi
 
-	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV &> /dev/null
+	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV >/dev/null 2>&1
 
 	# Must run fsck after setting uninit_groups
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$2 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -102,7 +102,7 @@ ext4_test_uninit_groups()
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/iso9660/isofs.sh +1 -1
index 3533e76..f59bbde 100755
@@ -62,7 +62,7 @@ gen_fs_tree()
 
 		mkdir -p "$new_path"
 
-		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 &> /dev/null
+		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 >/dev/null 2>&1
 
 		gen_fs_tree "$new_path" $((cur_depth + 1))
 	done
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh +2 -2
index 4be2123..32a35ad 100755
@@ -80,11 +80,11 @@ TST_CLEANUP=do_clean
 until [ $LOOP_COUNT -gt $HOTPLUG05_LOOPS ]; do
 
 	# Start up SAR and give it a couple cycles to run
-	sar 1 0 &>/dev/null &
+	sar 1 0 >/dev/null 2>&1 &
 	sleep 2
 	# "sar 1 0" is supported before 'sysstat-8.1.4(include sar)',
 	# after that use "sar 1" instead of. Use 'ps -C sar' to check.
-	if ps -C sar &>/dev/null; then
+	if ps -C sar >/dev/null 2>&1; then
 		pkill sar
 		sar -P ALL 1 0 > $TMP/log_$$ &
 	else
testcases/kernel/numa/numa01.sh +2 -2
index 9c5f49a..0091f7c 100755
@@ -60,7 +60,7 @@ chk_ifexists()
 {
     RC=0
 
-    which $2 &>$LTPTMP/tst_numa.err || RC=$?
+    which $2 >$LTPTMP/tst_numa.err 2>&1 || RC=$?
     if [ $RC -ne 0 ]
     then
         tst_brkm TBROK NULL "$1: command $2 not found."
@@ -171,7 +171,7 @@ init()
         LTPTMP=$TMP/tst_numa.$$
     fi
 
-    mkdir -p $LTPTMP &>/dev/null || RC=$?
+    mkdir -p $LTPTMP >/dev/null 2>&1 || RC=$?
     if [ $RC -ne 0 ]
     then
          tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
testcases/kernel/security/mmc_security/ask_password.sh +2 -2
index 5136e13..e5b4357 100644
@@ -52,14 +52,14 @@ ask_password()
 		while [ -z "$passwd" ]; do
 			read -s -p "MMC password: " passwd; echo
 		done
-		if ! keyctl instantiate $1 "$passwd" $2 &>/dev/null; then
+		if ! keyctl instantiate $1 "$passwd" $2 >/dev/null 2>&1; then
 			echo "*** Wrong password! The card was not unlocked."
 			exit 1
 		fi
 		echo "Password accepted."
 
 		exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 ask_password || exit $RC
testcases/kernel/security/mmc_security/assign_password.sh +2 -2
index 442486c..5d1eec5 100644
@@ -57,14 +57,14 @@ assign_password()
 		echo "*** Passwords do not match."
 		exit 1
 	fi
-	if ! keyctl instantiate $1 "$newpasswd" $2 &>/dev/null; then
+	if ! keyctl instantiate $1 "$newpasswd" $2 >/dev/null 2>&1; then
 		echo "*** Error while assigning new password"
 		exit 1
 	fi
 	echo "Password assigned."
 
 	exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 assign_password || exit $RC
testcases/lib/daemonlib.sh +4 -4
index 3d67125..aa0a159 100644
@@ -48,7 +48,7 @@ start_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl start $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 start > /dev/null 2>&1
 	else
 		/etc/init.d/$1 start > /dev/null 2>&1
@@ -59,7 +59,7 @@ stop_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl stop $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 stop > /dev/null 2>&1
 	else
 		/etc/init.d/$1 stop > /dev/null 2>&1
@@ -70,7 +70,7 @@ status_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl status $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 status > /dev/null 2>&1
 	else
 		/etc/init.d/$1 status > /dev/null 2>&1
@@ -81,7 +81,7 @@ restart_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl restart $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 restart > /dev/null 2>&1
 	else
 		/etc/init.d/$1 restart > /dev/null 2>&1
testcases/open_posix_testsuite/stress/threads/helper.c +1 -1
index 9bcc4dd..d54a920 100644
@@ -29,7 +29,7 @@
 #!/bin/sh
 
 #monitor the system
-vmstat -n 120 180 &> monitor.txt &
+vmstat -n 120 180 >monitor.txt 2>&1 &
 
 #run the tests
 for TS in `ls -1 *.c`;
Signature · 1 line
2.10.2
author
#1 lore raw

PATCH v2 1/4 shell: fix bashisms: s/&>/>$1 2>&1/

Hi,

Quoted 457 lines
---
 ltpmenu                                                        |  2 +-
 runltplite.sh                                                  |  2 +-
 testcases/commands/cron/cron_neg_tests.sh                      |  4 ++--
 testcases/commands/cron/cron_pos_tests.sh                      |  6 +++---
 .../ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh | 10 +++++-----
 .../ext4-inode-version/ext4_inode_version_test.sh              |  6 +++---
 .../ext4-journal-checksum/ext4_journal_checksum.sh             |  6 +++---
 .../ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh          |  6 +++---
 .../ext4-persist-prealloc/ext4_persist_prealloc_test.sh        |  4 ++--
 .../ext4-subdir-limit/ext4_subdir_limit_test.sh                |  6 +++---
 .../ext4-uninit-groups/ext4_uninit_groups_test.sh              |  8 ++++----
 testcases/kernel/fs/iso9660/isofs.sh                           |  2 +-
 .../kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh      |  4 ++--
 testcases/kernel/numa/numa01.sh                                |  4 ++--
 testcases/kernel/security/mmc_security/ask_password.sh         |  4 ++--
 testcases/kernel/security/mmc_security/assign_password.sh      |  4 ++--
 testcases/lib/daemonlib.sh                                     |  8 ++++----
 testcases/open_posix_testsuite/stress/threads/helper.c         |  2 +-
 18 files changed, 44 insertions(+), 44 deletions(-)
ltpmenu +1 -1
index 6a2338b..38d38c0 100755
@@ -112,7 +112,7 @@ compile_ltp()
         0) \
             for cmd in cc make lex ;
             do \
-                which $cmd &>/tmp/runltp.err.$$ ;
+                which $cmd >/tmp/runltp.err.$$ 2>&1 ;
                 if [ $? -ne 0 ] ;
                     then \
                         display_info_msg "Compiling LTP testsuite" \
runltplite.sh +1 -1
index 00a1078..9313649 100755
@@ -295,7 +295,7 @@ main()
     }
 
     # check for required users and groups
-    ${LTPROOT}/IDcheck.sh &>/dev/null || \
+    ${LTPROOT}/IDcheck.sh >/dev/null 2>&1 || \
     {
         echo "WARNING: required users and groups not present"
         echo "WARNING: some test cases may fail"
testcases/commands/cron/cron_neg_tests.sh +2 -2
index 27f2137..9c3d6f6 100755
@@ -87,7 +87,7 @@ echo setuid test
 echo
 
 tmpscript=cron_neg01_test
-rm -rf $tmpscript.out &> /dev/null
+rm -rf $tmpscript.out >/dev/null 2>&1
 
 
 cat > /tmp/$tmpscript << EOF
@@ -127,7 +127,7 @@ else
 fi
 echo
 
-rm /tmp/$tmpscript* &> /dev/null
+rm /tmp/$tmpscript* >/dev/null 2>&1
 crontab -r
 
 # Restore crontab
testcases/commands/cron/cron_pos_tests.sh +3 -3
index 2dc4ecc..ece114c 100755
@@ -22,10 +22,10 @@ if [ $iam = "root" ]; then
 		exit 1
 	fi
 
-	mv $CRON_ALLOW $CRON_ALLOW.old &> /dev/null
+	mv $CRON_ALLOW $CRON_ALLOW.old >/dev/null 2>&1
 	su $1 -c "$0 $*"
         RC=$?
-	mv $CRON_ALLOW.old $CRON_ALLOW &> /dev/null
+	mv $CRON_ALLOW.old $CRON_ALLOW >/dev/null 2>&1
 	exit $RC
 fi
 
@@ -53,7 +53,7 @@ fi
 
 # 1. Add new job
 
-rm -rf /tmp/crontest &> /dev/null
+rm -rf /tmp/crontest >/dev/null 2>&1
 mkdir -p /tmp/crontest
 
 cat > /tmp/crontest/testjob_cron01 << EOF
testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh +5 -5
index 16f621f..a5215bd 100755
@@ -28,7 +28,7 @@ export TST_TOTAL=17
 # Case 17: mount ext4 partition to ext3
 ext4_test_remount()
 {
-	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -60,7 +60,7 @@ ext4_test_remount()
 	fi
 	umount mnt_point
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
@@ -78,13 +78,13 @@ ext4_test_delalloc_mballoc()
 {
 	tst_resm TINFO "isDelalloc: $1, isDirectIO: $2, Blocksize: $3, isAuto_da_alloc: $4"
 
-	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -105,7 +105,7 @@ ext4_test_delalloc_mballoc()
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh +3 -3
index ac8f021..ef02cc0 100755
@@ -33,13 +33,13 @@ ext4_test_128_inode_version()
 {
 	tst_resm TINFO "Test inode version is 32 bits with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o i_version $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -83,7 +83,7 @@ ext4_test_128_inode_version()
 # $1: file operation
 test_inode_version()
 {
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh +3 -3
index 87eb90b..2f357d8 100755
@@ -55,13 +55,13 @@ ext4_test_journal_checksum()
 		"journal_checksum: $checksum, " \
 		"journal_async_commit: $async_commit, barrier: $5"
 
-	mkfs.ext4 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o data=$1,commit=$2,$3,$4,barrier=$5 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -82,7 +82,7 @@ ext4_test_journal_checksum()
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh +3 -3
index ec1c6a3..c6ff7c2 100755
@@ -33,13 +33,13 @@ ext4_test_sec_timestamps()
 {
 	tst_resm TINFO "Test timestamps with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -74,7 +74,7 @@ ext4_test_nsec_timestamps()
 {
 	tst_resm TINFO "Test timestamps with 256 inode size"
 
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh +2 -2
index e2b81a2..2a4b699 100755
@@ -32,7 +32,7 @@ export TST_TOTAL=2
 # $1: 1024 or 4096
 ext4_test_persist_prealloc()
 {
-	mkfs.ext4 -I 256 -b $1 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $1 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -72,7 +72,7 @@ ext4_test_persist_prealloc()
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh +3 -3
index 3162d67..5cc0523 100755
@@ -59,14 +59,14 @@ ext4_run_case()
 	# only mkfs if block size has been changed,
 	# or previous case failed
 	if [ $prev_result -ne $PASS -o $4 -ne $prev_block_size ]; then
-		mkfs.ext4 -b $4 -I 256 $EXT4_DEV &> /dev/null
+		mkfs.ext4 -b $4 -I 256 $EXT4_DEV >/dev/null 2>&1
 		if [ $? -ne 0 ]; then
 			tst_resm TFAIL "failed to create ext4 filesystem"
 			return
 		fi
 		prev_block_size=$4
 
-		tune2fs -O extents $EXT4_DEV &> /dev/null
+		tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 	fi
 
 	prev_result=$FAIL
@@ -113,7 +113,7 @@ ext4_run_case()
 	fi
 
 	# run fsck to make sure the filesystem has no errors
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck: the filesystem has errors"
 		return
testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh +4 -4
index 4db846a..1b0e00b 100755
@@ -66,7 +66,7 @@ ext4_test_uninit_groups()
 {
 	echo "Test $TST_COUNT" >> ext4_uninit_groups_result.txt
 
-	mkfs.ext4 -I 256 -m 0 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -m 0 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -78,10 +78,10 @@ ext4_test_uninit_groups()
 		flag=$3
 	fi
 
-	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV &> /dev/null
+	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV >/dev/null 2>&1
 
 	# Must run fsck after setting uninit_groups
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$2 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -102,7 +102,7 @@ ext4_test_uninit_groups()
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
testcases/kernel/fs/iso9660/isofs.sh +1 -1
index 3533e76..f59bbde 100755
@@ -62,7 +62,7 @@ gen_fs_tree()
 
 		mkdir -p "$new_path"
 
-		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 &> /dev/null
+		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 >/dev/null 2>&1
 
 		gen_fs_tree "$new_path" $((cur_depth + 1))
 	done
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh +2 -2
index 4be2123..32a35ad 100755
@@ -80,11 +80,11 @@ TST_CLEANUP=do_clean
 until [ $LOOP_COUNT -gt $HOTPLUG05_LOOPS ]; do
 
 	# Start up SAR and give it a couple cycles to run
-	sar 1 0 &>/dev/null &
+	sar 1 0 >/dev/null 2>&1 &
 	sleep 2
 	# "sar 1 0" is supported before 'sysstat-8.1.4(include sar)',
 	# after that use "sar 1" instead of. Use 'ps -C sar' to check.
-	if ps -C sar &>/dev/null; then
+	if ps -C sar >/dev/null 2>&1; then
 		pkill sar
 		sar -P ALL 1 0 > $TMP/log_$$ &
 	else
testcases/kernel/numa/numa01.sh +2 -2
index 9c5f49a..0091f7c 100755
@@ -60,7 +60,7 @@ chk_ifexists()
 {
     RC=0
 
-    which $2 &>$LTPTMP/tst_numa.err || RC=$?
+    which $2 >$LTPTMP/tst_numa.err 2>&1 || RC=$?
     if [ $RC -ne 0 ]
     then
         tst_brkm TBROK NULL "$1: command $2 not found."
@@ -171,7 +171,7 @@ init()
         LTPTMP=$TMP/tst_numa.$$
     fi
 
-    mkdir -p $LTPTMP &>/dev/null || RC=$?
+    mkdir -p $LTPTMP >/dev/null 2>&1 || RC=$?
     if [ $RC -ne 0 ]
     then
          tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
testcases/kernel/security/mmc_security/ask_password.sh +2 -2
index 5136e13..e5b4357 100644
@@ -52,14 +52,14 @@ ask_password()
 		while [ -z "$passwd" ]; do
 			read -s -p "MMC password: " passwd; echo
 		done
-		if ! keyctl instantiate $1 "$passwd" $2 &>/dev/null; then
+		if ! keyctl instantiate $1 "$passwd" $2 >/dev/null 2>&1; then
 			echo "*** Wrong password! The card was not unlocked."
 			exit 1
 		fi
 		echo "Password accepted."
 
 		exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 ask_password || exit $RC
testcases/kernel/security/mmc_security/assign_password.sh +2 -2
index 442486c..5d1eec5 100644
@@ -57,14 +57,14 @@ assign_password()
 		echo "*** Passwords do not match."
 		exit 1
 	fi
-	if ! keyctl instantiate $1 "$newpasswd" $2 &>/dev/null; then
+	if ! keyctl instantiate $1 "$newpasswd" $2 >/dev/null 2>&1; then
 		echo "*** Error while assigning new password"
 		exit 1
 	fi
 	echo "Password assigned."
 
 	exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 assign_password || exit $RC
testcases/lib/daemonlib.sh +4 -4
index 3d67125..aa0a159 100644
@@ -48,7 +48,7 @@ start_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl start $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 start > /dev/null 2>&1
 	else
 		/etc/init.d/$1 start > /dev/null 2>&1
@@ -59,7 +59,7 @@ stop_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl stop $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 stop > /dev/null 2>&1
 	else
 		/etc/init.d/$1 stop > /dev/null 2>&1
@@ -70,7 +70,7 @@ status_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl status $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 status > /dev/null 2>&1
 	else
 		/etc/init.d/$1 status > /dev/null 2>&1
@@ -81,7 +81,7 @@ restart_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl restart $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 restart > /dev/null 2>&1
 	else
 		/etc/init.d/$1 restart > /dev/null 2>&1
testcases/open_posix_testsuite/stress/threads/helper.c +0 -0
index 9bcc4dd..d54a920 100644

testcases/open_posix_testsuite/stress/threads/helper.c line 35

Quoted 8 lines
testcases/open_posix_testsuite/stress/threads/helper.c +1 -1
@@ -29,7 +29,7 @@
 #!/bin/sh
 
 #monitor the system
-vmstat -n 120 180 &> monitor.txt &
+vmstat -n 120 180 >monitor.txt 2>&1 &
 
 #run the tests
 for TS in `ls -1 *.c`;

This is actually first version, sorry for confusion.

Kind regards,
Petr

author
#2 lore raw

PATCH v2 2/4 make-file.sh: simplify, fix bashism

In reply to Petr Vorel
---
 tools/make-file.sh | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
tools/make-file.sh +1 -5
index becaeb0..ebfeb50 100755
@@ -35,10 +35,6 @@ fi
 
 [ -e "$file" ] && exit 0
 
-if ! perl -e "print 'A' x $size" > "$file" 2> /dev/null ; then
-	if ! awk 'BEGIN { cnt='$size'; while (cnt--) printf "A" }' > "$file" 2> /dev/null ; then
-		( while ((size--)) ; do echo -n A ; done ) > "$file"
-	fi
-fi
+while [ $((size=size-1)) -ge 0 ]; do printf "A" ; done > "$file"
 
 chmod 666 $file
Signature · 1 line
2.10.2
author
#3 lore raw

PATCH v2 3/4 shell: fix bashism (( ))

In reply to Petr Vorel
---
 testcases/kernel/device-drivers/zram/zram01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/device-drivers/zram/zram01.sh +1 -1
index caa0e05..64284d5 100755
@@ -54,7 +54,7 @@ zram_fill_fs()
 	for i in $(seq 0 $(($dev_num - 1))); do
 		tst_resm TINFO "fill zram$i..."
 		local b=0
-		while ((1)); do
+		while true; do
 			dd conv=notrunc if=/dev/zero of=zram${i}/file \
 				oflag=append count=1 bs=1024 status=none \
 				> /dev/null 2>&1 || break
Signature · 1 line
2.10.2
author
#4 lore raw

PATCH v2 4/4 shell: fix echo -e bashisms, simplify code

In reply to Petr Vorel
---
 testcases/commands/sssd/sssd-lib.sh                |   8 +-
 testcases/kernel/fs/acl/tacl_xattr.sh              | 114 ++++++++++-----------
 .../realtime/func/periodic_cpu_load/mixed_load.sh  |   2 +-
 testcases/realtime/perf/latency/run_auto.sh        |  14 +--
 testcases/realtime/run.sh                          |   6 +-
 testscripts/test_realtime.sh                       |  37 +++----
 tools/pounder21/test_scripts/statslogging          |  14 +--
 tools/strace_test/slay                             |   2 +-
 8 files changed, 99 insertions(+), 98 deletions(-)
testcases/commands/sssd/sssd-lib.sh +4 -4
index ab16fd4..aa70856 100755
@@ -161,10 +161,10 @@ restart_sssd_daemon()
 #id_provider = local
 make_config_file()
 {
-	echo -e "[sssd]\nconfig_file_version = 2" > $CONFIG_FILE
-	echo -e "services = nss, pam\ndomains = LOCAL" >> $CONFIG_FILE
-	echo -e "\n[nss]\n\n[pam]\n" >> $CONFIG_FILE
-	echo -e "[domain/LOCAL]\nid_provider = local" >> $CONFIG_FILE
+	printf "[sssd]\nconfig_file_version = 2\n" > $CONFIG_FILE
+	printf "services = nss, pam\ndomains = LOCAL\n" >> $CONFIG_FILE
+	printf "\n[nss]\n\n[pam]\n\n" >> $CONFIG_FILE
+	printf "[domain/LOCAL]\nid_provider = local\n" >> $CONFIG_FILE
 }
 
 . cmdlib.sh
testcases/kernel/fs/acl/tacl_xattr.sh +57 -57

318 lines not on this page · raw message

testcases/realtime/func/periodic_cpu_load/mixed_load.sh +1 -1
index 931d18f..173c2c0 100644
@@ -226,7 +226,7 @@ else
     RET=1
 fi
 
-echo -e "\nTest complete, see logs pcl-\$CONCURRENTx-t\$THREAD-\$NUM.log for detailed results."
+printf "\nTest complete, see logs pcl-\$CONCURRENTx-t\$THREAD-\$NUM.log for detailed results.\n"
 echo "Criteria: < 10% Difference in average runs"
 echo "Result: $RESULT"
 
testcases/realtime/perf/latency/run_auto.sh +7 -7
index 2c0d203..3311c1e 100755
@@ -8,9 +8,9 @@ fi
 source $SCRIPTS_DIR/setenv.sh
 LOG_FILE="$LOG_DIR/$LOG_FORMAT-pthread_cond_many.log"
 
-echo -e "Logging to: " | tee -a $LOG_FILE
-echo -e "$LOG_FILE " | tee -a $LOG_FILE
-echo -e "and to local individual .out files " | tee -a $LOG_FILE
+echo "Logging to: " | tee -a $LOG_FILE
+echo "$LOG_FILE " | tee -a $LOG_FILE
+echo "and to local individual .out files " | tee -a $LOG_FILE
 
 #
 # make will eventually go away from here, as will the above echoes
@@ -26,10 +26,10 @@ nthread=5000
 iter=400
 nproc=5
 
-echo -e "pthread_cond_many configuration:" | tee -a $LOG_FILE
-echo -e "number of threads = $nthread " | tee -a $LOG_FILE
-echo -e "number of iterations = $iter " | tee -a $LOG_FILE
-echo -e "number of processes = $nproc " | tee -a $LOG_FILE
+echo "pthread_cond_many configuration:" | tee -a $LOG_FILE
+echo "number of threads = $nthread " | tee -a $LOG_FILE
+echo "number of iterations = $iter " | tee -a $LOG_FILE
+echo "number of processes = $nproc " | tee -a $LOG_FILE
 
 # Remove any existing local log files
 rm -f $nthread.$iter.$nproc.*.out
testcases/realtime/run.sh +3 -3
index 07bdc83..174b36d 100755
@@ -71,9 +71,9 @@ list_tests()
 	pushd $TESTS_DIR >/dev/null
 	for file in `find -name run_auto.sh`
 	do
-		echo -e " `dirname  $file `"
+		echo " `dirname  $file `"
 	done
-		echo -e " \n"
+		printf " \n\n"
 }
 
 run_test()
@@ -103,7 +103,7 @@ run_test()
 		fi
 		pushd $TESTS_DIR >/dev/null
 	else
-		echo -e "\n $test is not a valid test subdirectory "
+		printf "\n $test is not a valid test subdirectory \n"
 		usage
 		exit 1
 	fi
testscripts/test_realtime.sh +19 -18
index e741309..a50f479 100755
@@ -41,38 +41,39 @@ fi
 
 function usage()
 {
-	echo -e "\nUsage: test_realtime.sh  -t test-argument [-l loop num_of_iterations] [-t test-argument1 [-l loop ...]] ..."
-	echo -e "\nWhere test-argument = func | stress | perf | all | list | clean | test_name"
-	echo -e "\nand:\n"
-	echo -e " func = 	all functional tests will be run "
-	echo -e " stress = 	all stress tests will be run "
-	echo -e " perf = 	all perf tests will be run "
-	echo -e " all =		all tests will be run "
-	echo -e " list = 	all available tests will be listed "
-	echo -e " clean = 	all logs deleted, make clean performed "
-	echo -e " test_name = 	only test_name subdir will be run (e.g: func/pi-tests) "
-	echo -e "\n"
+	cat <<EOF
+Usage: test_realtime.sh  -t test-argument [-l loop num_of_iterations] [-t test-argument1 [-l loop ...]] ...
+
+ test-argument: func | stress | perf | all | list | clean | test_name
+ func:	 	all functional tests will be run
+ stress: 	all stress tests will be run
+ perf:		all perf tests will be run
+ all:		all tests will be run
+ list:	 	all available tests will be listed
+ clean: 	all logs deleted, make clean performed
+ test_name:	only test_name subdir will be run (e.g: func/pi-tests)
+EOF
 	exit 1;
 }
 
 function check_error()
 {
         if [ $? -gt 0 ]; then
-        echo -e "\n $1 Failed\n"
+        printf "\n $1 Failed\n\n"
         exit 1
         fi
 }
 
 list_tests()
 {
-	echo -e "\nAvailable tests are:\n"
+	printf "\nAvailable tests are:\n\n"
 
 	cd $TESTS_DIR
 	for file in `find -name run_auto.sh`
 	do
-		echo -e " `dirname  $file `"
+		printf " `dirname  $file `\n"
 	done
-		echo -e " \n"
+		printf " \n\n"
 }
 
 function run_test()
@@ -97,11 +98,11 @@ function run_test()
                 ./run_auto.sh
                 done
             else
-                echo -e "\n Failed to find run script in $test \n"
+                printf "\n Failed to find run script in $test \n\n"
             fi
             pushd $TESTS_DIR >/dev/null
         else
-                echo -e "\n $test is not a valid test subdirectory "
+                printf "\n $test is not a valid test subdirectory \n"
                 usage
                 exit 1
         fi
@@ -156,7 +157,7 @@ find_test()
             done
                 pushd $TESTS_DIR >/dev/null
         else
-            echo -e "\n $subdir not found; check name/path with run.sh list "
+            printf "\n $subdir not found; check name/path with run.sh list \n"
         fi
     done
 
tools/pounder21/test_scripts/statslogging +7 -7
index 5185054..f1774ec 100755
@@ -38,13 +38,13 @@ INFOFILE=info
 #generic system info
 function sysinfo() {
 	uname -a >> $INFOFILE
-	echo -e "\n[cpuinfo]=================" >>$INFOFILE
+	printf "\n[cpuinfo]=================\n" >>$INFOFILE
 	cat /proc/cpuinfo >> $INFOFILE
-	echo -e "\n[meminfo]=================" >>$INFOFILE
+	printf "\n[meminfo]=================\n" >>$INFOFILE
 	cat /proc/meminfo >> $INFOFILE
-	echo -e "\n[ifinfo]=================" >>$INFOFILE
+	printf "\n[ifinfo]=================\n" >>$INFOFILE
 	/sbin/ifconfig >> $INFOFILE
-	echo -e "\n[sysctl]=================" >>$INFOFILE
+	printf "\n[sysctl]=================\n" >>$INFOFILE
 	sysctl -a >> $INFOFILE
 }
 
@@ -55,7 +55,7 @@ function procinfo() {
 	for i in $PROC_ENTRIES
 	do
 		logfile=`basename $i`
-		echo -e "\n$NOW" >> $logfile.log
+		printf "\n$NOW\n" >> $logfile.log
 		cat /proc/$i >> $logfile.log
 		sleep 1
 	done
@@ -73,7 +73,7 @@ function singleshots(){
 	while true; do
 		vmstat $DELAY $COUNT >> vmstat.log
 		NOW=`date`
-		echo -e "\n$NOW\n" >> vmstat.log
+		printf "\n$NOW\n\n" >> vmstat.log
 	done &
 
 	IOSTAT=`which iostat 2> /dev/null`
@@ -81,7 +81,7 @@ function singleshots(){
 		while true; do
 			iostat -x $DELAY $COUNT >> iostat.log
 			NOW=`date`
-			echo -e "\n$NOW\n" >> iostat.log
+			printf "\n$NOW\n\n" >> iostat.log
 		done &
 	fi
 }
tools/strace_test/slay +1 -1
index a68e8c9..7c0fe07 100755
@@ -119,7 +119,7 @@ do
     echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
   else
     echo "${ME}: Sending $SIGSHOW signal to $1's process(es)..."
-    echo -e "\\n\\n\\nYour current session has been terminated.\\n\\n\\n" | \
+    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \
     	write $1 2>/dev/null
   fi
   if [ "$SIGNAL" = "-clean" ]
Signature · 1 line
2.10.2
#5 lore raw

PATCH v2 4/4 shell: fix echo -e bashisms, simplify code

Hi!

testcases/kernel/fs/acl/tacl_xattr.sh if [ $? != 0 ] · line 88

Quoted 8 lines
testcases/kernel/fs/acl/tacl_xattr.sh +1 -1
@@ -85,7 +85,7 @@ if [ $? != 0 ]
 then
 	echo ""
 	echo "FAILED:  [ losetup ] Must have loop device support by kernel"
-	echo -e "\t to execute this script"
+	printf "\t to execute this script\n"

I guess that it's a bit cleaner to use printf for the whole block just to be consistent.

tools/strace_test/slay do · line 119

Quoted 6 lines
tools/strace_test/slay +0 -0
index a68e8c9..7c0fe07 100755
@@ -119,7 +119,7 @@ do
     echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
         ^
	 Missed one?

tools/strace_test/slay do · line 125

Quoted 7 lines
tools/strace_test/slay +1 -1
   else
     echo "${ME}: Sending $SIGSHOW signal to $1's process(es)..."
-    echo -e "\\n\\n\\nYour current session has been terminated.\\n\\n\\n" | \
+    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \
     	write $1 2>/dev/null
   fi
   if [ "$SIGNAL" = "-clean" ]

Apart from that the patchset is obviously correct.

Signature · 2 lines
Cyril Hrubis
[email protected]
#6 lore raw

PATCH v2 4/4 shell: fix echo -e bashisms, simplify code

Hi Cyril,

thanks for your review!

Quoted 11 lines

testcases/kernel/fs/acl/tacl_xattr.sh if [ $? != 0 ] · line 88

Quoted 8 lines
testcases/kernel/fs/acl/tacl_xattr.sh +1 -1
@@ -85,7 +85,7 @@ if [ $? != 0 ]
 then
 	echo ""
 	echo "FAILED:  [ losetup ] Must have loop device support by kernel"
-	echo -e "\t to execute this script"
+	printf "\t to execute this script\n"

I guess that it's a bit cleaner to use printf for the whole block just to be consistent.

Eh, missed it while checking result. I might use cat << EOF

Quoted 8 lines

tools/strace_test/slay do · line 119

Quoted 6 lines
tools/strace_test/slay +0 -0
index a68e8c9..7c0fe07 100755
@@ -119,7 +119,7 @@ do
     echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
         ^
	 Missed one?

Imperfect regex, I'll fix it.

Quoted 9 lines

tools/strace_test/slay do · line 125

Quoted 7 lines
tools/strace_test/slay +1 -1
   else
     echo "${ME}: Sending $SIGSHOW signal to $1's process(es)..."
-    echo -e "\\n\\n\\nYour current session has been terminated.\\n\\n\\n" | \
+    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \
     	write $1 2>/dev/null
   fi
   if [ "$SIGNAL" = "-clean" ]

Apart from that the patchset is obviously correct.

Kind regards,
Petr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20161128/796bf125/attachment.sig>