Followed advice of Open Group about shell command "test"

This commit is contained in:
Thomas Schmitt 2019-12-22 17:02:02 +01:00
parent b97841b782
commit 239244157b
1 changed files with 12 additions and 12 deletions

View File

@ -499,7 +499,7 @@ xdt_list_devices() {
fi fi
for xdt_trans in $xdt_transports for xdt_trans in $xdt_transports
do do
if test "$xdt_trans" = "usb" -o "$xdt_trans" = "mmcblk" if test "$xdt_trans" = "usb" || test "$xdt_trans" = "mmcblk"
then then
xdt_good_trans="${xdt_trans}+" xdt_good_trans="${xdt_trans}+"
elif test -n "$xdt_trans" elif test -n "$xdt_trans"
@ -517,7 +517,7 @@ xdt_list_devices() {
fi fi
fi fi
done done
if test -z "$xdt_good_trans" -a -z "$xdt_bad_trans" if test -z "$xdt_good_trans" && test -z "$xdt_bad_trans"
then then
xdt_yucky=y xdt_yucky=y
xdt_reasons="${xdt_reasons}no_bus_info- " xdt_reasons="${xdt_reasons}no_bus_info- "
@ -565,7 +565,7 @@ xdt_list_devices() {
# Decide whether the found filesystems look dispensible enough # Decide whether the found filesystems look dispensible enough
xdt_reasons="${xdt_reasons}${xdt_good_fs}${xdt_bad_fs}" xdt_reasons="${xdt_reasons}${xdt_good_fs}${xdt_bad_fs}"
if test "${xdt_bad_fs}${xdt_good_fs}" = "" \ if test "${xdt_bad_fs}${xdt_good_fs}" = "" \
-a -z "$xdt_have_su_power" && test -z "$xdt_have_su_power"
then then
xdt_yucky=y xdt_yucky=y
xdt_reasons="${xdt_reasons}no_fs_while_not_su- " xdt_reasons="${xdt_reasons}no_fs_while_not_su- "
@ -584,7 +584,7 @@ xdt_list_devices() {
fi fi
# Optional tests for size # Optional tests for size
if test -n "$xdt_max_size" -o -n "$xdt_min_size" if test -n "$xdt_max_size" || test -n "$xdt_min_size"
then then
xdt_size=$("$xdt_lsblk_cmd" -n -b -o SIZE /dev/"$xdt_name" \ xdt_size=$("$xdt_lsblk_cmd" -n -b -o SIZE /dev/"$xdt_name" \
| head -1 | xdt_round_down_div_million) | head -1 | xdt_round_down_div_million)
@ -594,7 +594,7 @@ xdt_list_devices() {
xdt_reasons="${xdt_reasons}lsblk_no_size- " xdt_reasons="${xdt_reasons}lsblk_no_size- "
fi fi
fi fi
if test -n "$xdt_max_size" -a -n "$xdt_size" if test -n "$xdt_max_size" && test -n "$xdt_size"
then then
if test "$xdt_size" -gt "$xdt_max_size" if test "$xdt_size" -gt "$xdt_max_size"
then then
@ -602,7 +602,7 @@ xdt_list_devices() {
xdt_reasons="${xdt_reasons}size_too_large- " xdt_reasons="${xdt_reasons}size_too_large- "
fi fi
fi fi
if test -n "$xdt_min_size" -a -n "$xdt_size" if test -n "$xdt_min_size" && test -n "$xdt_size"
then then
if test "$xdt_size" -lt "$xdt_min_size" if test "$xdt_size" -lt "$xdt_min_size"
then then
@ -757,13 +757,13 @@ xdt_decide_writing()
xdt_candidates=$(xdt_list_devices | tr '\n\r' ' ') xdt_candidates=$(xdt_list_devices | tr '\n\r' ' ')
xdt_num_cand=$(echo $xdt_candidates | wc -w) xdt_num_cand=$(echo $xdt_candidates | wc -w)
xdt_num_devs=$(echo $xdt_devs| wc -w) xdt_num_devs=$(echo $xdt_devs| wc -w)
if test -n "$xdt_dummy_force" -a "$xdt_num_devs" -ne 1 if test -n "$xdt_dummy_force" && test "$xdt_num_devs" -ne 1
then then
echo "SORRY: Refusing -dummy_force with not exactly one device given." >&2 echo "SORRY: Refusing -dummy_force with not exactly one device given." >&2
return 10 return 10
fi fi
if test -n "$xdt_dummy_force" -a -n "$xdt_dummy_run" \ if test -n "$xdt_dummy_force" && test -n "$xdt_dummy_run" \
-a "$xdt_num_cand" -ne 1 && test "$xdt_num_cand" -ne 1
then then
# -dummy_force in a situation where the program would normally refuse # -dummy_force in a situation where the program would normally refuse
echo echo
@ -791,8 +791,8 @@ xdt_decide_writing()
echo "Last chance to abort. Enter the word 'yes' to start REAL WRITING." >&2 echo "Last chance to abort. Enter the word 'yes' to start REAL WRITING." >&2
fi fi
read xdt_dummy read xdt_dummy
if test "$xdt_dummy" = "yes" -o "$xdt_dummy" = "'yes'" \ if test "X$xdt_dummy" = "Xyes" || test "X$xdt_dummy" = "X'yes'" \
-o "$xdt_dummy" = '"yes"' || test "X$xdt_dummy" = 'X"yes"'
then then
xdt_dummy=dummy xdt_dummy=dummy
else else
@ -856,7 +856,7 @@ xdt_main()
xdt_list_devices || return "$?" xdt_list_devices || return "$?"
if test -z "$xdt_list_all" -a -n "$xdt_do_write" if test -z "$xdt_list_all" && test -n "$xdt_do_write"
then then
xdt_decide_writing || return "$?" xdt_decide_writing || return "$?"
fi fi