shell: fix bashisms: s/&>/>$1 2>&1/
PATCH v3 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v3 2/4 make-file.sh: simplify, fix bashism
--- tools/make-file.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
tools/make-file.sh +1 -5
@@ -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
PATCH v3 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
@@ -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
PATCH v3 4/4 shell: fix echo -e bashisms, simplify code
In reply to Petr Vorel---
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(-)
testcases/commands/sssd/sssd-lib.sh +5 -5
@@ -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
testcases/kernel/fs/acl/tacl_xattr.sh +122 -190
538 lines not on this page · raw message
testcases/realtime/func/periodic_cpu_load/mixed_load.sh +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 +4 -4
@@ -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" ]
Signature · 1 line
2.10.2
PATCH v3 4/4 shell: fix echo -e bashisms, simplify code
Hi!
Quoted 10 lines
Signed-off-by Petr Vorel <[email protected]>---
Changesv2->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.
Quoted 7 lines
tools/strace_test/slay +0
-0@@ -115,11 +115,11 @@ do COOL="1" if [ "$SLAY_BUTTHEAD" = "on" ]
tools/strace_test/slay do · line 122
Quoted 10 lines
tools/strace_test/slay +4
-4then - 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.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 4/4 shell: fix echo -e bashisms, simplify code
Quoted 10 lines · Cyril Hrubis
Hi!
tools/strace_test/slay do · line 122
Quoted 5 lines
Signed-off-by Petr Vorel <[email protected]>tools/strace_test/slay +2
-2- 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
PATCH v3 4/4 shell: fix echo -e bashisms, simplify code
In reply to Cyril HrubisHi Cyril,
Quoted 7 lines
The
tacl_xattr.shshould 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_scriptsdirectory. So simple git grepping will not help in this case.
Good to know.
Quoted 1 line
The
mixed_load.shseems to be unused, probably leftover.
It would be great if you could do the cleanup.
Quoted 14 lines
Quoted 14 lines
tools/strace_test/slay +2
-3@@ -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)..."
Quoted 8 lines
tools/strace_test/slay do · line 122
Quoted 3 lines
tools/strace_test/slay +2
-1- 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).
Quoted 1 line
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>