All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 1/4] shell: fix bashisms: s/&>/>$1 2>&1/
@ 2016-11-29  8:22 Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 2/4] make-file.sh: simplify, fix bashism Petr Vorel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Petr Vorel @ 2016-11-29  8:22 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 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(-)

diff --git a/ltpmenu b/ltpmenu
index 6a2338b..38d38c0 100755
--- a/ltpmenu
+++ b/ltpmenu
@@ -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" \
diff --git a/runltplite.sh b/runltplite.sh
index 00a1078..9313649 100755
--- a/runltplite.sh
+++ b/runltplite.sh
@@ -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"
diff --git a/testcases/commands/cron/cron_neg_tests.sh b/testcases/commands/cron/cron_neg_tests.sh
index 27f2137..9c3d6f6 100755
--- a/testcases/commands/cron/cron_neg_tests.sh
+++ b/testcases/commands/cron/cron_neg_tests.sh
@@ -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
diff --git a/testcases/commands/cron/cron_pos_tests.sh b/testcases/commands/cron/cron_pos_tests.sh
index 2dc4ecc..ece114c 100755
--- a/testcases/commands/cron/cron_pos_tests.sh
+++ b/testcases/commands/cron/cron_pos_tests.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh b/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
index 16f621f..a5215bd 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
index ac8f021..ef02cc0 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh b/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
index 87eb90b..2f357d8 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
index ec1c6a3..c6ff7c2 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
index e2b81a2..2a4b699 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
index 3162d67..5cc0523 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
@@ -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
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
index 4db846a..1b0e00b 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
@@ -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
diff --git a/testcases/kernel/fs/iso9660/isofs.sh b/testcases/kernel/fs/iso9660/isofs.sh
index 3533e76..f59bbde 100755
--- a/testcases/kernel/fs/iso9660/isofs.sh
+++ b/testcases/kernel/fs/iso9660/isofs.sh
@@ -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
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
index 4be2123..32a35ad 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
@@ -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
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 9c5f49a..0091f7c 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -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"
diff --git a/testcases/kernel/security/mmc_security/ask_password.sh b/testcases/kernel/security/mmc_security/ask_password.sh
index 5136e13..e5b4357 100644
--- a/testcases/kernel/security/mmc_security/ask_password.sh
+++ b/testcases/kernel/security/mmc_security/ask_password.sh
@@ -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
diff --git a/testcases/kernel/security/mmc_security/assign_password.sh b/testcases/kernel/security/mmc_security/assign_password.sh
index 442486c..5d1eec5 100644
--- a/testcases/kernel/security/mmc_security/assign_password.sh
+++ b/testcases/kernel/security/mmc_security/assign_password.sh
@@ -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
diff --git a/testcases/lib/daemonlib.sh b/testcases/lib/daemonlib.sh
index 3d67125..aa0a159 100644
--- a/testcases/lib/daemonlib.sh
+++ b/testcases/lib/daemonlib.sh
@@ -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
diff --git a/testcases/open_posix_testsuite/stress/threads/helper.c b/testcases/open_posix_testsuite/stress/threads/helper.c
index 9bcc4dd..d54a920 100644
--- a/testcases/open_posix_testsuite/stress/threads/helper.c
+++ b/testcases/open_posix_testsuite/stress/threads/helper.c
@@ -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`;
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 2/4] make-file.sh: simplify, fix bashism
  2016-11-29  8:22 [LTP] [PATCH v3 1/4] shell: fix bashisms: s/&>/>$1 2>&1/ Petr Vorel
@ 2016-11-29  8:22 ` Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 3/4] shell: fix bashism (( )) Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code Petr Vorel
  2 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2016-11-29  8:22 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 tools/make-file.sh | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/make-file.sh b/tools/make-file.sh
index becaeb0..ebfeb50 100755
--- a/tools/make-file.sh
+++ b/tools/make-file.sh
@@ -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
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 3/4] shell: fix bashism (( ))
  2016-11-29  8:22 [LTP] [PATCH v3 1/4] shell: fix bashisms: s/&>/>$1 2>&1/ Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 2/4] make-file.sh: simplify, fix bashism Petr Vorel
@ 2016-11-29  8:22 ` Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code Petr Vorel
  2 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2016-11-29  8:22 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 testcases/kernel/device-drivers/zram/zram01.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index caa0e05..64284d5 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -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
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code
  2016-11-29  8:22 [LTP] [PATCH v3 1/4] shell: fix bashisms: s/&>/>$1 2>&1/ Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 2/4] make-file.sh: simplify, fix bashism Petr Vorel
  2016-11-29  8:22 ` [LTP] [PATCH v3 3/4] shell: fix bashism (( )) Petr Vorel
@ 2016-11-29  8:22 ` Petr Vorel
  2016-12-01 15:26   ` Cyril Hrubis
  2 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2016-11-29  8:22 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Changes v2->v3:
* convert one more echo -e (slay)
* use printf consistently (tacl_xattr.sh, slay)

There could have been more cleanup done in (tacl_xattr.sh: print errors into
stderr, ...), but some script aren't called anywhere (tacl_xattr.sh,
statslogging, mixed_load.sh, slay), I suppose I should have delete them instead
of fixing.
---
 testcases/commands/sssd/sssd-lib.sh                |  10 +-
 testcases/kernel/fs/acl/tacl_xattr.sh              | 312 ++++++++-------------
 .../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                             |   8 +-
 8 files changed, 168 insertions(+), 235 deletions(-)

diff --git a/testcases/commands/sssd/sssd-lib.sh b/testcases/commands/sssd/sssd-lib.sh
index ab16fd4..be72e1f 100755
--- a/testcases/commands/sssd/sssd-lib.sh
+++ b/testcases/commands/sssd/sssd-lib.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 #
 #  Copyright (c) 2012 FUJITSU LIMITED
 #
@@ -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
diff --git a/testcases/kernel/fs/acl/tacl_xattr.sh b/testcases/kernel/fs/acl/tacl_xattr.sh
index 039bd17..c2383fd 100755
--- a/testcases/kernel/fs/acl/tacl_xattr.sh
+++ b/testcases/kernel/fs/acl/tacl_xattr.sh
@@ -83,9 +83,8 @@ chmod 777 tacl/blkext2
 losetup /dev/loop0 tacl/blkext2 >/dev/null 2>&1
 if [ $? != 0 ]
 then
-	echo ""
-	echo "FAILED:  [ losetup ] Must have loop device support by kernel"
-	echo -e "\t to execute this script"
+	printf "\nFAILED:  [ losetup ] Must have loop device support by kernel\n"
+	printf "\t to execute this script\n"
 	exit 1
 fi
 
@@ -97,10 +96,9 @@ then
 	mount -t ext3 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ mount ] Make sure that ACL (Access Control List)"
-		echo -e "\t and Extended Attribute are built into the kernel"
-		echo -e "\t Can not mount ext2 file system with acl and user_xattr options"
+		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
+		printf "\t and Extended Attribute are built into the kernel\n"
+		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
 		exit 1
 	fi
 
@@ -110,10 +108,9 @@ else
 	mount -t ext2 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ mount ] Make sure that ACL (Access Control List)"
-		echo -e "\t and Extended Attribute are built into the kernel"
-		echo -e "\t Can not mount ext2 file system with acl and user_xattr options"
+		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
+		printf "\t and Extended Attribute are built into the kernel\n"
+		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
 		exit 1
 	fi
 fi
@@ -179,23 +176,19 @@ su - tacluser1 << TACL_USER1
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] Create file must be denied by file permission bits"
-		echo -e "\t [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
+		printf "\t [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: Create file denied by file permission bits [ Physical directory ]"
+		printf "\nSUCCESS: Create file denied by file permission bits [ Physical directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] Create file must be denied by file permission bits"
-		echo -e "\t [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
+		printf "\t [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: Create file denied by file permission bits [ Symlink directory ]"
+		printf "\nSUCCESS: Create file denied by file permission bits [ Symlink directory ]\n"
 	fi
 
 TACL_USER1
@@ -216,25 +209,21 @@ su - tacluser1 << TACL_USER1
 	cd $CUR_PATH/tacl/mount-ext2/shared/team1/ 2> /dev/null
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner execute"
-		echo -e "\t permissions, but operation failed [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
+		printf "\t permissions, but operation failed [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions, "
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	cd $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/ 2> /dev/null
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED: [ touch ] ACL_USER_OBJ  entry already contains the owner execute"
-		echo -e "\t permissions, but operation failed [ Symlink Directory ]"
+		printf "\nFAILED: [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
+		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER1
@@ -246,25 +235,21 @@ su - tacluser1 << TACL_USER1
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write "
-		echo -e "\t permissions, but operation failed [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
+		printf "\t permissions, but operation failed [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write "
-		echo -e "\t permissions, but operation failed [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
+		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER1
@@ -286,25 +271,21 @@ su - tacluser3 << TACL_USER3
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions, "
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_USER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Physical Directory ]"
+		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions, "
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_USER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER3
@@ -316,29 +297,25 @@ su - tacluser3 << TACL_USER3
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER entry contains the user permissions"
-		echo -e "\t but ACL_MASK are set --- , "
-		echo -e "\t operation must be denied [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
+		printf "\t but ACL_MASK are set --- ,\n"
+		printf "\t operation must be denied [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions,"
-		echo -e "\t but ACL_MASK are set ___ ,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t but ACL_MASK are set ___ ,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER entry contains the user permissions"
-		echo -e "\t but ACL_MASK are set --- ,"
-		echo -e "\t operation must be denied [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
+		printf "\t but ACL_MASK are set --- ,\n"
+		printf "\t operation must be denied [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions,"
-		echo -e "\t but ACL_MASK are set ___ ,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t but ACL_MASK are set ___ ,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER3
@@ -370,25 +347,21 @@ su - tacluser2 << TACL_USER2
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry contains the group permissions,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,"
-		echo -e "\t but option success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
+		printf "\t but option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry contains the group permissions,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,"
-		echo -e "\t but option success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
+		printf "\t but option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -399,29 +372,25 @@ su - tacluser2 << TACL_USER2
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry already contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---, "
-		echo -e "\t option must no be success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry already contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -434,25 +403,21 @@ su - tacluser2 << TACL_USER2
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,"
-		echo -e "\t but option denied [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
+		printf "\t but option denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,"
-		echo -e "\t but option denied [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
+		printf "\t but option denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -463,29 +428,25 @@ su - tacluser2 << TACL_USER2
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---, "
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -505,25 +466,21 @@ su - tacluser4 << TACL_USER4
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_OTHER entry contains the user permissions,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Physical Directory ]"
+		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_OTHER entry contains the user permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER4
@@ -535,21 +492,17 @@ su - tacluser4 << TACL_USER4
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 ]
 	then
-		echo ""
-		echo "SUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]"
+		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]"
+		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 ]
 	then
-		echo ""
-		echo "SUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]"
+		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
 	fi
 
 TACL_USER4
@@ -583,11 +536,9 @@ RES=`echo $CONTENT | grep ".r--r--r--" | awk '{print $1}'`
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 
@@ -611,11 +562,9 @@ RES=`echo $CONTENT | grep ".r--rw-r--" | awk '{print $1}'`
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 #
@@ -638,11 +587,9 @@ RES=`echo $CONTENT | grep ".rw-rw-rw-" | awk '{print \$1}'`
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 
@@ -673,19 +620,15 @@ then
 	then
 		if [ $OTHER_PERMISSION = "other::rwx" ]
 		then
-			echo ""
-			echo "SUCCESS: Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are correct"
+			printf "\nSUCCESS: Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are correct\n"
 		else
-			echo ""
-			echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+			printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 		fi
 	else
-		echo ""
-		echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+		printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 	fi
 else
-	echo ""
-	echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+	printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 fi
 
 
@@ -706,11 +649,9 @@ if [ $ITEM_OWNER = "tacluser2" ]
 then
 	if [ $ITEM_GROUP = "tacluser2" ]
 	then
-		echo ""
-		echo "SUCCESS: Chown correct"
+		printf "\nSUCCESS: Chown correct\n"
 	else
-		echo ""
-		echo "FAILED:  Chown are not correct"
+		printf "\nFAILED:  Chown are not correct\n"
 	fi
 else
 	echo "FAILED:  Chown are not correct"
@@ -729,15 +670,12 @@ getfacl -RL tacl/mount-ext2/ > tacl/tmp2
 
 if [ `diff tacl/tmp1 tacl/tmp2` ]
 then
-	echo ""
-	echo "FAILED:  ACLs backup and restore are not correct"
+	printf "\nFAILED:  ACLs backup and restore are not correct\n"
 else
-	echo ""
-	echo "SUCCESS: ACLs backup and restore are correct"
+	printf "\nSUCCESS: ACLs backup and restore are correct\n"
 fi
 
-echo ""
-echo -e "\tEnd ACLs Test"
+printf "\n\tEnd ACLs Test\n"
 
 #####################################################
 #
@@ -745,13 +683,10 @@ echo -e "\tEnd ACLs Test"
 #
 #####################################################
 
-echo
-echo "Now begin Extend Attribute Test"
+printf "\nNow begin Extend Attribute Test\n"
 
 # dir
-echo
-echo "Attach name:value pair to object dir "
-echo ""
+printf "\nAttach name:value pair to object dir\n\n"
 attr -s attrname1 -V attrvalue1 tacl/mount-ext2/shared/team2
 if [ $? != 0 ]
 then
@@ -849,15 +784,12 @@ setfattr -h --restore=tacl/backup.ea
 getfattr -dhR -m- -e hex tacl/mount-ext2 > tacl/backup.ea1
 if [ `diff  tacl/backup.ea1  tacl/backup.ea` ]
 then
-        echo ""
-        echo "FAILED:  EAs backup and restore are not correct"
+        printf "\nFAILED:  EAs backup and restore are not correct\n"
 else
-        echo ""
-        echo "SUCCESS: EAs backup and restore are correct"
+        printf "\nSUCCESS: EAs backup and restore are correct\n"
 fi
 
-echo ""
-echo -e "\tEnd EAs Test"
+printf "\n\tEnd EAs Test\n"
 
 
 
diff --git a/testcases/realtime/func/periodic_cpu_load/mixed_load.sh b/testcases/realtime/func/periodic_cpu_load/mixed_load.sh
index 931d18f..173c2c0 100644
--- a/testcases/realtime/func/periodic_cpu_load/mixed_load.sh
+++ b/testcases/realtime/func/periodic_cpu_load/mixed_load.sh
@@ -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"
 
diff --git a/testcases/realtime/perf/latency/run_auto.sh b/testcases/realtime/perf/latency/run_auto.sh
index 2c0d203..3311c1e 100755
--- a/testcases/realtime/perf/latency/run_auto.sh
+++ b/testcases/realtime/perf/latency/run_auto.sh
@@ -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
diff --git a/testcases/realtime/run.sh b/testcases/realtime/run.sh
index 07bdc83..174b36d 100755
--- a/testcases/realtime/run.sh
+++ b/testcases/realtime/run.sh
@@ -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
diff --git a/testscripts/test_realtime.sh b/testscripts/test_realtime.sh
index e741309..a50f479 100755
--- a/testscripts/test_realtime.sh
+++ b/testscripts/test_realtime.sh
@@ -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
 
diff --git a/tools/pounder21/test_scripts/statslogging b/tools/pounder21/test_scripts/statslogging
index 5185054..f1774ec 100755
--- a/tools/pounder21/test_scripts/statslogging
+++ b/tools/pounder21/test_scripts/statslogging
@@ -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
 }
diff --git a/tools/strace_test/slay b/tools/strace_test/slay
index a68e8c9..d3571c0 100755
--- a/tools/strace_test/slay
+++ b/tools/strace_test/slay
@@ -115,11 +115,11 @@ do
   COOL="1"
   if [ "$SLAY_BUTTHEAD" = "on" ]
   then
-    echo "${ME}: $SIGSHOW is kicking $1's butt!"
-    echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
+    printf "${ME}: $SIGSHOW is kicking $1's butt!\n"
+    printf "\\n\\n\\nI'm kicking your butt.\\n\\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 "${ME}: Sending $SIGSHOW signal to $1's process(es)...\n"
+    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \
     	write $1 2>/dev/null
   fi
   if [ "$SIGNAL" = "-clean" ]
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code
  2016-11-29  8:22 ` [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code Petr Vorel
@ 2016-12-01 15:26   ` Cyril Hrubis
  2016-12-01 15:51     ` Peter Maydell
  2016-12-01 16:56     ` Petr Vorel
  0 siblings, 2 replies; 7+ messages in thread
From: Cyril Hrubis @ 2016-12-01 15:26 UTC (permalink / raw)
  To: ltp

Hi!
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> ---
> Changes v2->v3:
> * convert one more echo -e (slay)
> * use printf consistently (tacl_xattr.sh, slay)
> 
> There could have been more cleanup done in (tacl_xattr.sh: print errors into
> stderr, ...), but some script aren't called anywhere (tacl_xattr.sh,
> statslogging, mixed_load.sh, slay), I suppose I should have delete them instead
> of fixing.

The script slay seems to be called from go_go.sh, quite likely the whole
strace_test is not useful for anything these days when we have several
syscall fuzzers available. We should most likely get rid of the whole
strace_test directory.

The tacl_xattr.sh should be probably investigated and either fixed or
removed.

The statslogging script seems to be part of pounder21, there are some
tar archives that contain test screnarios with symlinks that may point
to the files in the test_scripts directory. So simple git grepping will
not help in this case.

The mixed_load.sh seems to be unused, probably leftover.

> diff --git a/tools/strace_test/slay b/tools/strace_test/slay
> index a68e8c9..d3571c0 100755
> --- a/tools/strace_test/slay
> +++ b/tools/strace_test/slay
> @@ -115,11 +115,11 @@ do
>    COOL="1"
>    if [ "$SLAY_BUTTHEAD" = "on" ]
>    then
> -    echo "${ME}: $SIGSHOW is kicking $1's butt!"
> -    echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
> +    printf "${ME}: $SIGSHOW is kicking $1's butt!\n"
> +    printf "\\n\\n\\nI'm kicking your butt.\\n\\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 "${ME}: Sending $SIGSHOW signal to $1's process(es)...\n"
> +    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \

I'm a bit puzzled by the double backslashes here. I guess that the
double backslash is reduced by shell to a single backslash and then
echo/printf command gets just plain old \n in ARGV[]. But as this code
will likely get removed anyway I've applied this patch as it is.


Whole series applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code
  2016-12-01 15:26   ` Cyril Hrubis
@ 2016-12-01 15:51     ` Peter Maydell
  2016-12-01 16:56     ` Petr Vorel
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2016-12-01 15:51 UTC (permalink / raw)
  To: ltp

On 1 December 2016 at 15:26, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
>> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
>> -    echo "${ME}: Sending $SIGSHOW signal to $1's process(es)..."
>> -    echo -e "\\n\\n\\nYour current session has been terminated.\\n\\n\\n" | \
>> +    printf "${ME}: Sending $SIGSHOW signal to $1's process(es)...\n"
>> +    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \
>
> I'm a bit puzzled by the double backslashes here. I guess that the
> double backslash is reduced by shell to a single backslash and then
> echo/printf command gets just plain old \n in ARGV[].

Yes. In shell double-quoted text backslashes function as an escape
character when they precede any of $ ` " \ <newline>.
So "Hello\\n" becomes "Hello\n" as the executed command
sees it, and then printf/echo interpret \n as the newline.
You could also write that as 'Hello\n', since single-quotes don't
do backslash-escaping, or indeed as "Hello\n", since 'n' isn't
one of the handful of punctuation characters that need backslash
escapes inside double-quotes, and the shell is required not to
give backslash any special meaning if it isn't followed by one
of those. (This is why the first 'printf' in the bit I quote
above works even though it's just "${ME} ...\n" rather than \\n.)

Conclusion: those \\n could be tidied up to be just \n if you
want, but they're harmless.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code
  2016-12-01 15:26   ` Cyril Hrubis
  2016-12-01 15:51     ` Peter Maydell
@ 2016-12-01 16:56     ` Petr Vorel
  1 sibling, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2016-12-01 16:56 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> The tacl_xattr.sh should be probably investigated and either fixed or
> removed.

> The statslogging script seems to be part of pounder21, there are some
> tar archives that contain test screnarios with symlinks that may point
> to the files in the test_scripts directory. So simple git grepping will
> not help in this case.
Good to know.

> The mixed_load.sh seems to be unused, probably leftover.
It would be great if you could do the cleanup.

> > diff --git a/tools/strace_test/slay b/tools/strace_test/slay
> > index a68e8c9..d3571c0 100755
> > --- a/tools/strace_test/slay
> > +++ b/tools/strace_test/slay
> > @@ -115,11 +115,11 @@ do
> >    COOL="1"
> >    if [ "$SLAY_BUTTHEAD" = "on" ]
> >    then
> > -    echo "${ME}: $SIGSHOW is kicking $1's butt!"
> > -    echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
> > +    printf "${ME}: $SIGSHOW is kicking $1's butt!\n"
> > +    printf "\\n\\n\\nI'm kicking your butt.\\n\\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 "${ME}: Sending $SIGSHOW signal to $1's process(es)...\n"
> > +    printf "\\n\\n\\nYour current session has been terminated.\\n\\n\\n\n" | \

> I'm a bit puzzled by the double backslashes here. I guess that the
> double backslash is reduced by shell to a single backslash and then
> echo/printf command gets just plain old \n in ARGV[]. But as this code
> will likely get removed anyway I've applied this patch as it is.
Eh, you (and Peter Maydell) are right. I'm sorry, I'll have to check it twice next time
(especially when I replace with perl one liners).


> Whole series applied, thanks.
Thanks a lot!


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/20161201/089bc671/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-12-01 16:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29  8:22 [LTP] [PATCH v3 1/4] shell: fix bashisms: s/&>/>$1 2>&1/ Petr Vorel
2016-11-29  8:22 ` [LTP] [PATCH v3 2/4] make-file.sh: simplify, fix bashism Petr Vorel
2016-11-29  8:22 ` [LTP] [PATCH v3 3/4] shell: fix bashism (( )) Petr Vorel
2016-11-29  8:22 ` [LTP] [PATCH v3 4/4] shell: fix echo -e bashisms, simplify code Petr Vorel
2016-12-01 15:26   ` Cyril Hrubis
2016-12-01 15:51     ` Peter Maydell
2016-12-01 16:56     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.