[PATCH] Use one form of command substitution.
by Roman Rakus
It's good to use only one form of command substituion. It's preferred to use
$() instead of ``. $() allows nesting without quoting.
Signed-off-by: Roman Rakus <rrakus(a)redhat.com>
---
src/analyze.sh | 2 +-
src/beakerlib.sh | 2 +-
src/examples/apache/runtest.sh | 4 +-
src/examples/phases/runtest.sh | 2 +-
src/infrastructure.sh | 10 ++++----
src/journal.sh | 10 ++++----
src/logging.sh | 24 +++++++++++-----------
src/performance.sh | 12 +++++-----
src/test/coverageTest.sh | 4 +-
src/test/infrastructureTest.sh | 6 ++--
src/test/journalTest.sh | 10 ++++----
src/test/loggingTest.sh | 42 ++++++++++++++++++++--------------------
src/test/test.sh | 6 ++--
src/test/testingTest.sh | 22 ++++++++++----------
src/testing.sh | 26 ++++++++++++------------
15 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/src/analyze.sh b/src/analyze.sh
index eb47b85..5da1cd3 100644
--- a/src/analyze.sh
+++ b/src/analyze.sh
@@ -78,7 +78,7 @@ Return 0 if... TODO
rlDejaSum(){
rlLog "Summarizing files: $1 $2"
rlLogDebug "Calling beakerlib-deja-summarize routine"
- sumfile=`mktemp`
+ sumfile=$(mktemp)
beakerlib-deja-summarize $1 $2 | while read line
do
rlLog "$line"
diff --git a/src/beakerlib.sh b/src/beakerlib.sh
index 07a78d0..cfe78eb 100644
--- a/src/beakerlib.sh
+++ b/src/beakerlib.sh
@@ -125,7 +125,7 @@ the recommended variables and makes use of the phases:
# Setup phase: Prepare test directory
rlPhaseStartSetup
rlAssertRpm $PACKAGE
- rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
+ rlRun 'TmpDir=$(mktemp -d)' 0 'Creating tmp directory'
rlRun "pushd $TmpDir"
rlPhaseEnd
diff --git a/src/examples/apache/runtest.sh b/src/examples/apache/runtest.sh
index bb0f2ce..a404bbe 100755
--- a/src/examples/apache/runtest.sh
+++ b/src/examples/apache/runtest.sh
@@ -44,7 +44,7 @@ rlJournalStart
rlAssertRpm "httpd"
# Use rlRun to check the exit status of a command (0 expected here)
- rlRun "TmpDir=\`mktemp -d\`" 0
+ rlRun 'TmpDir=$(mktemp -d)' 0
pushd $TmpDir
# Add a comment to make the final report more readable
@@ -66,7 +66,7 @@ rlJournalStart
# Check whether the page has been successfully fetched
rlAssertExists "index.html"
# Log page content
- rlLog "index.html contains: `cat index.html`"
+ rlLog "index.html contains: $(<index.html)"
# Make sure the content is OK
rlAssertGrep "Welcome to Test Page" "index.html"
# Check the access log for the corresponding record
diff --git a/src/examples/phases/runtest.sh b/src/examples/phases/runtest.sh
index 467b178..18d7862 100755
--- a/src/examples/phases/runtest.sh
+++ b/src/examples/phases/runtest.sh
@@ -39,7 +39,7 @@ rlJournalStart
# Setup phase: Prepare test directory
rlPhaseStartSetup
rlAssertRpm $PACKAGE
- rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
+ rlRun 'TmpDir=$(mktemp -d)' 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
diff --git a/src/infrastructure.sh b/src/infrastructure.sh
index d1349ce..44348b4 100644
--- a/src/infrastructure.sh
+++ b/src/infrastructure.sh
@@ -478,7 +478,7 @@ rlServiceStart() {
local status=$?
# if the original state hasn't been saved yet, do it now!
- local wasRunning="__INTERNAL_SERVICE_STATE_`echo $service|sed 's/[^a-zA-Z]//g'`"
+ local wasRunning="__INTERNAL_SERVICE_STATE_$(echo $service|sed 's/[^a-zA-Z]//g')"
if [ -z "${!wasRunning}" ]; then
# was running
if [ $status == 0 ]; then
@@ -561,7 +561,7 @@ rlServiceStop() {
local status=$?
# if the original state hasn't been saved yet, do it now!
- local wasRunning="__INTERNAL_SERVICE_STATE_`echo $service|sed 's/[^a-zA-Z]//g'`"
+ local wasRunning="__INTERNAL_SERVICE_STATE_$(echo $service|sed 's/[^a-zA-Z]//g')"
if [ -z "${!wasRunning}" ]; then
# was running
if [ $status == 0 ]; then
@@ -634,7 +634,7 @@ rlServiceRestore() {
for service in $@; do
# if the original state hasn't been saved, then something's wrong
- local wasRunning="__INTERNAL_SERVICE_STATE_`echo $service|sed 's/[^a-zA-Z]//g'`"
+ local wasRunning="__INTERNAL_SERVICE_STATE_$(echo $service|sed 's/[^a-zA-Z]//g')"
if [ -z "${!wasRunning}" ]; then
rlLogError "rlServiceRestore: Original state of $service was not saved, nothing to do"
((failed++))
@@ -642,8 +642,8 @@ rlServiceRestore() {
fi
${!wasRunning} && wasStopped=false || wasStopped=true
- rlLogDebug "rlServiceRestore: Restoring $service to original state (`
- $wasStopped && echo "stopped" || echo "running"`)"
+ rlLogDebug "rlServiceRestore: Restoring $service to original state ($(
+ $wasStopped && echo "stopped" || echo "running"))"
# find out current state
service $service status
diff --git a/src/journal.sh b/src/journal.sh
index 8d6a1a2..f42b1f4 100644
--- a/src/journal.sh
+++ b/src/journal.sh
@@ -75,8 +75,8 @@ rlJournalStart(){
[ -d $BEAKERLIB_DIR ] || mkdir $BEAKERLIB_DIR
# otherwise we generate a random run id using mktemp
else
- export BEAKERLIB_DIR=`mktemp -d /tmp/beakerlib-XXXXXXX`
- export BEAKERLIB_RUN=`echo $BEAKERLIB_DIR | sed 's|.*-||'`
+ export BEAKERLIB_DIR=$(mktemp -d /tmp/beakerlib-XXXXXXX)
+ export BEAKERLIB_RUN=$(echo $BEAKERLIB_DIR | sed 's|.*-||')
fi
# set global BeakerLib journal variable for future use
export BEAKERLIB_JOURNAL="$BEAKERLIB_DIR/journal.xml"
@@ -331,11 +331,11 @@ rljAddPhase(){
rljClosePhase(){
local out
- out=`$__INTERNAL_JOURNALIST finphase --id $BEAKERLIB_RUN`
+ out=$($__INTERNAL_JOURNALIST finphase --id $BEAKERLIB_RUN)
local score=$?
local logfile="$BEAKERLIB_DIR/journal.txt"
- local result="`echo $out | cut -d ':' -f 2`"
- local name=`echo $out | cut -d ':' -f 3 | sed 's/[^[:alnum:]]\+/-/g'`
+ local result="$(echo $out | cut -d ':' -f 2)"
+ local name=$(echo $out | cut -d ':' -f 3 | sed 's/[^[:alnum:]]\+/-/g')
rlLogDebug "rljClosePhase: Phase $name closed"
rlJournalPrintText > $logfile
rlReport "$name" "$result" "$score" "$logfile"
diff --git a/src/logging.sh b/src/logging.sh
index 81181a8..da6a2c9 100644
--- a/src/logging.sh
+++ b/src/logging.sh
@@ -64,8 +64,8 @@ __INTERNAL_LogText() {
__INTERNAL_FileSubmit() {
local FILENAME="$4"
- rlLog "File '$FILENAME' stored here: /tmp/BEAKERLIB_STORED_`basename $FILENAME`"
- cp -f "$FILENAME" /tmp/BEAKERLIB_STORED_`basename $FILENAME`
+ rlLog "File '$FILENAME' stored here: /tmp/BEAKERLIB_STORED_$(basename $FILENAME)"
+ cp -f "$FILENAME" /tmp/BEAKERLIB_STORED_$(basename $FILENAME)
return $?
}
@@ -115,7 +115,7 @@ Priority of the log.
=cut
rlLog() {
- __INTERNAL_LogText ":: [`date +%H:%M:%S`] :: $3 $1" "$2"
+ __INTERNAL_LogText ":: [$(date +%H:%M:%S)] :: $3 $1" "$2"
if [ "$3" == "" ]; then
rljAddMessage "$1" "LOG"
fi
@@ -315,7 +315,7 @@ rlFileSubmit -s '_' /etc/passwd -> etc_passwd
=cut
rlFileSubmit() {
- GETOPT=`getopt -q -o s: -- "$@"`
+ GETOPT=$(getopt -q -o s: -- "$@")
eval set -- "$GETOPT"
SEPARATOR='-'
@@ -333,23 +333,23 @@ rlFileSubmit() {
local RETVAL=-1
local FILE=$1
local ALIAS
- local TMPDIR=`mktemp -d`
+ local TMPDIR=$(mktemp -d)
if [ -f $FILE ]; then
if [ -n "$2" ]; then
ALIAS="$2"
else
if echo "$FILE" | egrep -q "^\.(\.)?/"; then
# ^ if the path is specified as relative ~ begins with ./ or ../
- local POM=`dirname "$FILE"`
- ALIAS=`cd "$POM"; pwd`
- ALIAS="$ALIAS/`basename $FILE`"
+ local POM=$(dirname "$FILE")
+ ALIAS=$(cd "$POM"; pwd)
+ ALIAS="$ALIAS/$(basename $FILE)"
else
ALIAS=$1
fi
- ALIAS=`echo $ALIAS | tr '/' "$SEPARATOR" | sed "s/^${SEPARATOR}*//"`
+ ALIAS=$(echo $ALIAS | tr '/' "$SEPARATOR" | sed "s/^${SEPARATOR}*//")
fi
rlLogInfo "Sending $FILE as $ALIAS"
- ln -s "`readlink -f $FILE`" "$TMPDIR/$ALIAS"
+ ln -s "$(readlink -f $FILE)" "$TMPDIR/$ALIAS"
if [ -z "$BEAKERLIB_COMMAND_SUBMIT_LOG" ]
then
@@ -397,7 +397,7 @@ rlShowPackageVersion()
for pkg in $@; do
if rpm -q $pkg &> /dev/null; then
IFS=$'\n'
- for line in `rpm -q $pkg --queryformat "$pkg RPM version: %{version}-%{release}.%{arch}\n"`
+ for line in $(rpm -q $pkg --queryformat "$pkg RPM version: %{version}-%{release}.%{arch}\n")
do
rlLog $line
done
@@ -512,7 +512,7 @@ Log a message with version of the currently running kernel.
=cut
rlShowRunningKernel() {
- rlLog "Kernel version: `uname -r`"
+ rlLog "Kernel version: $(uname -r)"
}
diff --git a/src/performance.sh b/src/performance.sh
index 53d175b..f4c61ac 100644
--- a/src/performance.sh
+++ b/src/performance.sh
@@ -157,16 +157,16 @@ rlPerfTime_AvgFromRuns(){
rlLog "Doing non-measured warmup run"
eval "$command"
fi
- local __INTERNAL_TIMER=`mktemp`
- for cnt in `seq $runs`; do
+ local __INTERNAL_TIMER=$(mktemp)
+ for cnt in $(seq $runs); do
/usr/bin/time -o $__INTERNAL_TIMER -f "bt=\"%U + %S\"" $command
. $__INTERNAL_TIMER
rlLog "Run $cnt took $bt seconds"
- total="`echo "scale=5; $total + $bt" | bc`"
+ total="$(echo "scale=5; $total + $bt" | bc)"
done
- rlLog "The average of $runs runs was `echo "scale=5; $total / $runs" | bc` seconds"
- echo "`echo "scale=5; $total / $runs" | bc`"
- export rl_retval="`echo "scale=5; $total / $runs" | bc`"
+ rlLog "The average of $runs runs was $(echo "scale=5; $total / $runs" | bc) seconds"
+ echo "$(echo "scale=5; $total / $runs" | bc)"
+ export rl_retval="$(echo "scale=5; $total / $runs" | bc)"
rm -f $__INTERNAL_TIMER
}
diff --git a/src/test/coverageTest.sh b/src/test/coverageTest.sh
index 5ea6443..dfd38c5 100644
--- a/src/test/coverageTest.sh
+++ b/src/test/coverageTest.sh
@@ -15,11 +15,11 @@
#tries to find test for every existing rl-function
test_coverage(){
- TEST_SCRIPTS=`ls *Test.sh|grep -v coverageTest.sh`
+ TEST_SCRIPTS=$(ls *Test.sh|grep -v coverageTest.sh)
#doesn't work with redirection, must use temp file instead
declare -f |grep '^rl.* ()' |grep -v '^rlj'|cut -d ' ' -f 1 >fnc.list
while read FUNCTION ; do
- assertTrue "Test coverage for $FUNCTION" "grep -q $FUNCTION `echo $TEST_SCRIPTS`"
+ assertTrue "Test coverage for $FUNCTION" "grep -q $FUNCTION $(echo $TEST_SCRIPTS)"
done < fnc.list
rm -f fnc.list
}
diff --git a/src/test/infrastructureTest.sh b/src/test/infrastructureTest.sh
index 7d47d6f..6e1900a 100644
--- a/src/test/infrastructureTest.sh
+++ b/src/test/infrastructureTest.sh
@@ -47,7 +47,7 @@ BackupSanityTest() {
}
# setup
- tmpdir=`mktemp -d /tmp/backup-test-XXXXXXX`
+ tmpdir=$(mktemp -d /tmp/backup-test-XXXXXXX)
pushd $tmpdir >/dev/null
# create files
@@ -201,7 +201,7 @@ test_rlFileBackupCleanAndRestoreWhitespace() {
test_rlFileBackup_MissingFiles() {
local dir
- assertTrue "Preparing the directory" 'dir=`mktemp -d` && pushd $dir && mkdir subdir'
+ assertTrue "Preparing the directory" 'dir=$(mktemp -d) && pushd $dir && mkdir subdir'
assertTrue "Changing selinux context" "chcon -t httpd_user_content_t subdir"
assertTrue "Saving the old context" "ls -lZd subdir > old"
assertRun "rlFileBackup --clean $dir/subdir/missing" 8 "Backing up"
@@ -216,7 +216,7 @@ test_rlFileBackup_MissingFiles() {
# backing up symlinks [BZ#647231]
test_rlFileBackup_Symlinks() {
local dir
- assertTrue "Preparing files" 'dir=`mktemp -d` && pushd $dir && touch file && ln -s file link'
+ assertTrue "Preparing files" 'dir=$(mktemp -d) && pushd $dir && touch file && ln -s file link'
assertRun "rlFileBackup link" "[07]" "Backing up the link"
assertTrue "Removing the link" "rm link"
assertRun "rlFileRestore link" "[02]" "Restoring the link"
diff --git a/src/test/journalTest.sh b/src/test/journalTest.sh
index a7ece26..e1e8f73 100644
--- a/src/test/journalTest.sh
+++ b/src/test/journalTest.sh
@@ -86,20 +86,20 @@ test_rlJournalPrintText(){
# no traceback on non-xml garbage
rlJournalStart
rlPhaseStart FAIL &> /dev/null
- rlLog "`echo $'\x00'`" &> /dev/null
+ rlLog "$(echo $'\x00')" &> /dev/null
assertFalse "no traceback on non-xml characters [1]" \
"rlJournalPrintText 2>&1 | grep Traceback"
- rlLog "`echo $'\x0c'`" &> /dev/null
+ rlLog "$(echo $'\x0c')" &> /dev/null
assertFalse "no traceback on non-xml characters [2]" \
"rlJournalPrintText 2>&1 | grep Traceback"
- rlLog "`echo $'\x1F'`" &> /dev/null
+ rlLog "$(echo $'\x1F')" &> /dev/null
assertFalse "no traceback on non-xml characters [3]" \
"rlJournalPrintText 2>&1 | grep Traceback"
rm -rf $BEAKERLIB_DIR
# multiline logs
rlJournalStart
- rlLog "`echo -e 'line1\nline2'`" &> /dev/null
+ rlLog "$(echo -e 'line1\nline2')" &> /dev/null
rlJournalPrintText | grep -v "line2" | grep -q "LOG.*line1" &&
rlJournalPrintText | grep -v "line1" | grep -q "LOG.*line2"
assertTrue "multiline logs tagged on each line" "[ $? -eq 0 ]"
@@ -125,7 +125,7 @@ test_rlGetTestState(){
assertRun 'rlAssert0 "failing assert#2" 1' 1
rlGetTestState ; assertTrue "rlGetTestState return 2 after assert failed" "[ $? -eq 2 ]"
rlGetPhaseState ; assertTrue "rlGetPhaseState return 2 after assert failed" "[ $? -eq 2 ]"
- assertRun 'for i in `seq 3 260` ; do rlAssert0 "failing assert#$i" 1; done' 1 "Creating 260 failed asserts"
+ assertRun 'for i in $(seq 3 260) ; do rlAssert0 "failing assert#$i" 1; done' 1 "Creating 260 failed asserts"
rlGetTestState ; assertTrue "rlGetTestState return 255 after more that 255 asserts failed" "[ $? -eq 255 ]"
rlGetPhaseState ; assertTrue "rlGetPhaseState return 255 after more that 255 asserts failed" "[ $? -eq 255 ]"
assertRun "rlPhaseEnd"
diff --git a/src/test/loggingTest.sh b/src/test/loggingTest.sh
index 8082abf..939a883 100644
--- a/src/test/loggingTest.sh
+++ b/src/test/loggingTest.sh
@@ -125,7 +125,7 @@ test_LogMetricLowHigh(){
#second metric called metrone - must not be inserted to journal
rlLogMetricLow metrone 345
assertTrue "metric insertion fails when name's not unique inside one phase" \
- "[ `rlJournalPrint | grep -c '<metric.*name=.metrone.*type=.low.'` -eq 1 ]"
+ "[ $(rlJournalPrint | grep -c '<metric.*name=.metrone.*type=.low.') -eq 1 ]"
rm -rf $BEAKERLIB_DIR
#same name of metric but in different phases - must work
@@ -134,13 +134,13 @@ test_LogMetricLowHigh(){
rlPhaseEnd &> /dev/null ; rlPhaseStartTest phase-2 &> /dev/null
rlLogMetricLow metrone 345
assertTrue "metric insertion succeeds when name's not unique but phases differ" \
- "[ `rlJournalPrint | grep -c '<metric.*name=.metrone.*type=.low.'` -eq 2 ]"
+ "[ $(rlJournalPrint | grep -c '<metric.*name=.metrone.*type=.low.') -eq 2 ]"
}
test_rlShowRunningKernel(){
rlJournalStart; rlPhaseStart FAIL &> /dev/null
rlShowRunningKernel &> /dev/null
- assertTrue "kernel version is logged" "rlJournalPrintText |grep -q `uname -r`"
+ assertTrue "kernel version is logged" "rlJournalPrintText |grep -q $(uname -r)"
}
__checkLoggedPkgInfo() {
@@ -194,7 +194,7 @@ test_rlShowPackageVersion() {
: >$OUTPUTFILE
# Test with package this_package_do_not_exist
- assertFalse 'rlShowPackageVersion returns 1 when some packages do not exists' "rlShowPackageVersion this_package_do_not_exist `echo $few` this_package_do_not_exist_too"
+ assertFalse 'rlShowPackageVersion returns 1 when some packages do not exists' "rlShowPackageVersion this_package_do_not_exist $(echo $few) this_package_do_not_exist_too"
: >$OUTPUTFILE
rm -f $list
@@ -293,7 +293,7 @@ test_LOG_LEVEL(){
}
test_rlFileSubmit() {
- local main_dir=`pwd`
+ local main_dir=$(pwd)
local prefix=rlFileSubmit-unittest
local upload_to=$prefix/uploaded
local hlp_files=$prefix/hlp_files
@@ -328,15 +328,15 @@ EOF
rlFileSubmit rlFileSubmit_test1.file &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs file without relative or absolute path specified' "[ $? -eq 0 ]"
# TEST 2: Relative path ./
local orig_file="$hlp_files/rlFileSubmit_test2.file"
- local alias=`echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//"`
+ local alias=$(echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//")
local expected_file="$upload_to/$alias"
echo "rlFileSubmit_test2" > $orig_file
@@ -345,8 +345,8 @@ EOF
rlFileSubmit ./rlFileSubmit_test2.file &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs relative path ./' "[ $? -eq 0 ]"
@@ -354,7 +354,7 @@ EOF
# TEST 3: Relative path ../
mkdir -p $hlp_files/directory/
local orig_file="$hlp_files/rlFileSubmit_test3.file"
- local alias=`echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//"`
+ local alias=$(echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//")
local expected_file="$upload_to/$alias"
echo "rlFileSubmit_test3" > $orig_file
@@ -363,15 +363,15 @@ EOF
rlFileSubmit ../rlFileSubmit_test3.file &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs relative path ../' "[ $? -eq 0 ]"
# TEST 4: Absolute path
local orig_file="$hlp_files/rlFileSubmit_test4.file"
- local alias=`echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//"`
+ local alias=$(echo "$main_dir/$orig_file" | tr '/' "-" | sed "s/^-*//")
local expected_file="$upload_to/$alias"
echo "rlFileSubmit_test4" > $orig_file
@@ -379,8 +379,8 @@ EOF
rlFileSubmit $main_dir/$orig_file &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs absolute path' "[ $? -eq 0 ]"
@@ -395,15 +395,15 @@ EOF
rlFileSubmit $orig_file $alias &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs custom alias' "[ $? -eq 0 ]"
# TEST 6: Custom separator
local orig_file="$hlp_files/rlFileSubmit_test6.file"
- local alias=`echo "$main_dir/$orig_file" | tr '/' "_" | sed "s/^_*//"`
+ local alias=$(echo "$main_dir/$orig_file" | tr '/' "_" | sed "s/^_*//")
local expected_file="$upload_to/$alias"
echo "rlFileSubmit_test6" > $orig_file
@@ -411,8 +411,8 @@ EOF
rlFileSubmit -s '_' $main_dir/$orig_file &> /dev/null
cd $main_dir
- local sum1=`md5sum $orig_file | cut -d " " -f 1`
- local sum2=`md5sum $expected_file | cut -d " " -f 1`
+ local sum1=$(md5sum $orig_file | cut -d " " -f 1)
+ local sum2=$(md5sum $expected_file | cut -d " " -f 1)
[ -e $expected_file -a "$sum1" = "$sum2" ]
assertTrue 'rlBundleLogs absolute path' "[ $? -eq 0 ]"
diff --git a/src/test/test.sh b/src/test/test.sh
index 4af09de..b7b1e6f 100755
--- a/src/test/test.sh
+++ b/src/test/test.sh
@@ -251,7 +251,7 @@ export TESTID='123456'
export TEST='beakerlib-unit-tests'
. ../beakerlib.sh
export __INTERNAL_JOURNALIST="$BEAKERLIB/python/journalling.py"
-export OUTPUTFILE=`mktemp`
+export OUTPUTFILE=$(mktemp)
rlJournalStart
# check parameters for test list
@@ -269,7 +269,7 @@ for arg in "$@"; do
done
# unless test files specified run all available
-[[ -z "$FileList" ]] && FileList="`ls *Test.sh`"
+[[ -z "$FileList" ]] && FileList="$(ls *Test.sh)"
# load all test functions
for file in $FileList; do
@@ -280,7 +280,7 @@ done
if [[ -z "$TestList" ]]; then
for file in $FileList; do
assertStart ${file%Test.sh}
- for test in `grep -o '^test_[^ (]*' $file`; do
+ for test in $(grep -o '^test_[^ (]*' $file); do
assertLog "Running $test"
$test
done
diff --git a/src/test/testingTest.sh b/src/test/testingTest.sh
index 4126503..9dddfcd 100644
--- a/src/test/testingTest.sh
+++ b/src/test/testingTest.sh
@@ -14,9 +14,9 @@
# Author: Ales Zelinka <azelinka(a)redhat.com>
test_rlAssertDiffer() {
- local FILE1="`mktemp`"
- local FILE2="`mktemp`"
- local FILE3="`mktemp '/tmp/test rlAssertDiffer3-XXXXXX'`"
+ local FILE1="$(mktemp)"
+ local FILE2="$(mktemp)"
+ local FILE3="$(mktemp '/tmp/test rlAssertDiffer3-XXXXXX')"
echo "AAA" > "$FILE1"
echo "AAA" > "$FILE2"
@@ -52,9 +52,9 @@ test_rlAssertDiffer() {
}
test_rlAssertNotDiffer() {
- local FILE1="`mktemp`"
- local FILE2="`mktemp`"
- local FILE3="`mktemp '/tmp/test rlAssertNotDiffer3-XXXXXX'`"
+ local FILE1="$(mktemp)"
+ local FILE2="$(mktemp)"
+ local FILE3="$(mktemp '/tmp/test rlAssertNotDiffer3-XXXXXX')"
echo "AAA" > "$FILE1"
echo "AAA" > "$FILE2"
@@ -247,7 +247,7 @@ test_rlRun(){
assertTrue "rlRun tagging (stderr)" "[ $? -eq 0 ]"
OUTPUTFILE_orig="$OUTPUTFILE"
- export OUTPUTFILE="`mktemp`"
+ export OUTPUTFILE="$(mktemp)"
rlRun -l 'echo "foobar3"' 2>&1 1>/dev/null
grep 'echo "foobar3"' $OUTPUTFILE 1>/dev/null && egrep '^foobar3' $OUTPUTFILE 1>/dev/null
@@ -300,13 +300,13 @@ test_rlReport(){
for res in PASS FAIL WARN
do
- OUT="`rlReport TEST $res | grep ANCHOR`"
+ OUT="$(rlReport TEST $res | grep ANCHOR)"
assertTrue "testing basic rlReport functionality" "[ \"$OUT\" == \"ANCHOR NAME: TEST\nRESULT: $res\n LOGFILE: $OUTPUTFILE\nSCORE: \" ]"
- OUT="`rlReport \"TEST TEST\" $res | grep ANCHOR`"
+ OUT="$(rlReport \"TEST TEST\" $res | grep ANCHOR)"
assertTrue "testing if rlReport can handle spaces in test name" "[ \"$OUT\" == \"ANCHOR NAME: TEST TEST\nRESULT: $res\n LOGFILE: $OUTPUTFILE\nSCORE: \" ]"
- OUT="`rlReport \"TEST\" $res 5 \"/tmp/logname\" | grep ANCHOR`"
+ OUT="$(rlReport \"TEST\" $res 5 \"/tmp/logname\" | grep ANCHOR)"
assertTrue "testing if rlReport can handle all arguments" "[ \"$OUT\" == \"ANCHOR NAME: TEST\nRESULT: $res\n LOGFILE: /tmp/logname\nSCORE: 5\" ]"
- OUT="`rlReport \"TEST TEST\" $res 8 \"/tmp/log name\" | grep ANCHOR`"
+ OUT="$(rlReport \"TEST TEST\" $res 8 \"/tmp/log name\" | grep ANCHOR)"
assertTrue "testing if rlReport can handle spaces in test name and log file" "[ \"$OUT\" == \"ANCHOR NAME: TEST TEST\nRESULT: $res\n LOGFILE: /tmp/log name\nSCORE: 8\" ]"
done
rlPhaseEnd &> /dev/null
diff --git a/src/testing.sh b/src/testing.sh
index f934630..0632b39 100644
--- a/src/testing.sh
+++ b/src/testing.sh
@@ -208,7 +208,7 @@ rlAssertEquals() {
__INTERNAL_LogAndJournalFail "rlAssertEquals called without all needed parameters" ""
return 1
fi
- __INTERNAL_ConditionalAssert "$1" `[ "$2" == "$3" ]; echo $?` "(Assert: $2 should equal $3)"
+ __INTERNAL_ConditionalAssert "$1" $([ "$2" == "$3" ]; echo $?) "(Assert: $2 should equal $3)"
return $?
}
@@ -249,7 +249,7 @@ rlAssertNotEquals() {
__INTERNAL_LogAndJournalFail "rlAssertNotEquals called without all needed parameters" ""
return 1
fi
- __INTERNAL_ConditionalAssert "$1" `[ "$2" != "$3" ]; echo $?` "(Assert: \"$2\" should not equal \"$3\")"
+ __INTERNAL_ConditionalAssert "$1" $([ "$2" != "$3" ]; echo $?) "(Assert: \"$2\" should not equal \"$3\")"
return $?
}
@@ -286,7 +286,7 @@ Returns 0 and asserts PASS when C<value1 E<gt> value2>.
=cut
rlAssertGreater() {
- __INTERNAL_ConditionalAssert "$1" `[ "$2" -gt "$3" ]; echo $?` "(Assert: \"$2\" should be greater than \"$3\")"
+ __INTERNAL_ConditionalAssert "$1" $([ "$2" -gt "$3" ]; echo $?) "(Assert: \"$2\" should be greater than \"$3\")"
return $?
}
@@ -323,7 +323,7 @@ Returns 0 and asserts PASS when C<value1 E<gt>= value2>.
=cut
rlAssertGreaterOrEqual() {
- __INTERNAL_ConditionalAssert "$1" `[ "$2" -ge "$3" ]; echo $?` "(Assert: \"$2\" should be >= \"$3\")"
+ __INTERNAL_ConditionalAssert "$1" $([ "$2" -ge "$3" ]; echo $?) "(Assert: \"$2\" should be >= \"$3\")"
return $?
}
@@ -360,7 +360,7 @@ rlAssertExists(){
__INTERNAL_LogAndJournalFail "rlAssertExists called without parameter" ""
return 1
fi
- __INTERNAL_ConditionalAssert "File $1 should exist" `[ -e "$1" ]; echo $?`
+ __INTERNAL_ConditionalAssert "File $1 should exist" $([ -e "$1" ]; echo $?)
return $?
}
@@ -394,7 +394,7 @@ rlAssertNotExists(){
__INTERNAL_LogAndJournalFail "rlAssertNotExists called without parameter" ""
return 1
fi
- __INTERNAL_ConditionalAssert "File $1 should not exist" `[ ! -e "$1" ]; echo $?`
+ __INTERNAL_ConditionalAssert "File $1 should not exist" $([ ! -e "$1" ]; echo $?)
return $?
}
@@ -636,7 +636,7 @@ B<Warning:> using C<unbuffer> tool is now disabled because of bug 547686.
=cut
rlRun() {
- GETOPT=`getopt -q -o lts -- "$@"`
+ GETOPT=$(getopt -q -o lts -- "$@")
eval set -- "$GETOPT"
local DO_LOG=false
@@ -650,7 +650,7 @@ rlRun() {
case "$1" in
-l)
DO_LOG=true;
- [ -n "$LOG_FILE" ] || LOG_FILE=`mktemp`
+ [ -n "$LOG_FILE" ] || LOG_FILE=$(mktemp)
shift;;
-t)
DO_TAG=true;
@@ -659,7 +659,7 @@ rlRun() {
shift;;
-s)
DO_KEEP=true
- [ -n "$LOG_FILE" ] || LOG_FILE=`mktemp`
+ [ -n "$LOG_FILE" ] || LOG_FILE=$(mktemp)
shift;;
--)
shift;
@@ -732,7 +732,7 @@ rlRun() {
sync
fi
if $DO_LOG; then
- rlLog "$command\n`cat $LOG_FILE`"
+ rlLog "$command\n$(<$LOG_FILE)"
fi
if $DO_KEEP; then
rlRun_LOG=$LOG_FILE
@@ -878,9 +878,9 @@ rlReport() {
}
__INTERNAL_rlIsDistro(){
- local distro="`lsb_release -ds`"
- local whole="`lsb_release -rs`"
- local major="`lsb_release -rs | cut -d '.' -f 1`"
+ local distro="$(lsb_release -ds)"
+ local whole="$(lsb_release -rs)"
+ local major="$(lsb_release -rs | cut -d '.' -f 1)"
echo $distro | grep -q "$1" || return 1
shift
--
1.7.4
13 years, 1 month