Cleanup: fix problems reported by shell lint

Followup to #15616, which is not usable as it is (way, way, way
too much noise) but actually found a few real nits that should
be fixed.

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago 2022-09-15 16:18:46 -06:00
parent 750726e62c
commit cfbc4aaeb5
11 changed files with 27 additions and 27 deletions

View File

@ -106,7 +106,7 @@ export PODMAN_ROOTLESS_USER=$(id -un)
# Root # Root
if [ -z "$ROOTLESS_ONLY" ]; then if [ -z "$ROOTLESS_ONLY" ]; then
echo "# bats ${bats_filter[@]} $TESTS" echo "# bats ${bats_filter[*]} $TESTS"
sudo --preserve-env=PODMAN \ sudo --preserve-env=PODMAN \
--preserve-env=PODMAN_TEST_DEBUG \ --preserve-env=PODMAN_TEST_DEBUG \
--preserve-env=OCI_RUNTIME \ --preserve-env=OCI_RUNTIME \
@ -119,7 +119,7 @@ fi
# Rootless. (Only if we're not already root) # Rootless. (Only if we're not already root)
if [[ -z "$ROOT_ONLY" && "$(id -u)" != 0 ]]; then if [[ -z "$ROOT_ONLY" && "$(id -u)" != 0 ]]; then
echo "--------------------------------------------------" echo "--------------------------------------------------"
echo "\$ bats ${bats_filter[@]} $TESTS" echo "\$ bats ${bats_filter[*]} $TESTS"
bats "${bats_opts[@]}" "${bats_filter[@]}" $TESTS bats "${bats_opts[@]}" "${bats_filter[@]}" $TESTS
rc=$((rc | $?)) rc=$((rc | $?))
fi fi

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if ! [ $(id -u) = 0 ]; then if ! [ $(id -u) = 0 ]; then
echo "Please run as root! '$@' requires root privileges." echo "Please run as root! '$*' requires root privileges."
exit 1 exit 1
fi fi

View File

@ -87,7 +87,7 @@ function compare_usage() {
# strip off command name from both # strip off command name from both
from_man=$(sed -e "s/\*\*$cmd\*\*[[:space:]]*//" <<<"$from_man") from_man=$(sed -e "s/\*\*$cmd\*\*[[:space:]]*//" <<<"$from_man")
from_help=$(sed -e "s/^[[:space:]]*$cmd[[:space:]]*//" <<<"$from_help") from_help=$(sed -e "s/^[[:space:]]*${cmd}[[:space:]]*//" <<<"$from_help")
# man page lists 'foo [*options*]', help msg shows 'foo [flags]'. # man page lists 'foo [*options*]', help msg shows 'foo [flags]'.
# Make sure if one has it, the other does too. # Make sure if one has it, the other does too.
@ -153,7 +153,7 @@ for md in *.1.md;do
# special case: the command is "auto-update", with a hyphen # special case: the command is "auto-update", with a hyphen
md_nodash='podman auto-update' md_nodash='podman auto-update'
fi fi
if [ "$cmd" != "$md_nodash" -a "$cmd" != "podman-remote" ]; then if [[ "$cmd" != "$md_nodash" ]] && [[ "$cmd" != "podman-remote" ]]; then
echo echo
printf "Inconsistent program name in SYNOPSIS in %s:\n" $md printf "Inconsistent program name in SYNOPSIS in %s:\n" $md
printf " SYNOPSIS = %s (expected: '%s')\n" "$cmd" "$md_nodash" printf " SYNOPSIS = %s (expected: '%s')\n" "$cmd" "$md_nodash"

View File

@ -272,8 +272,8 @@ function t() {
esac esac
done done
if [[ -z "$curl_args" ]]; then if [[ -z "$curl_args" ]]; then
curl_args=(-d $(jsonify ${post_args[@]})) curl_args=(-d $(jsonify ${post_args[*]}))
testname="$testname [${curl_args[@]}]" testname="$testname [${curl_args[*]}]"
fi fi
fi fi
@ -336,7 +336,7 @@ function t() {
# Any error from curl is instant bad news, from which we can't recover # Any error from curl is instant bad news, from which we can't recover
if [[ $rc -ne 0 ]]; then if [[ $rc -ne 0 ]]; then
die "curl failure ($rc) on $url - cannot continue" die "curl failure ($rc) on $url - cannot continue. args=${curl_args[*]}"
fi fi
# Show returned headers (without trailing ^M or empty lines) in log file. # Show returned headers (without trailing ^M or empty lines) in log file.
@ -384,7 +384,7 @@ function t() {
# Special case: if response code does not match, dump the response body # Special case: if response code does not match, dump the response body
# and skip all further subtests. # and skip all further subtests.
if [[ $actual_code != $expected_code ]]; then if [[ "$actual_code" != "$expected_code" ]]; then
echo -e "# response: $output" echo -e "# response: $output"
for i; do for i; do
_show_ok skip "$testname: $i # skip - wrong return code" _show_ok skip "$testname: $i # skip - wrong return code"
@ -671,11 +671,11 @@ echo -e "collected ${#tests_to_run[@]} items\n"
start_service start_service
for i in ${tests_to_run[@]}; do for i in "${tests_to_run[@]}"; do
TEST_CONTEXT="[$(basename $i .at)]" TEST_CONTEXT="[$(basename $i .at)]"
# Clear output from 'podman' helper # Clear output from 'podman' helper
>| $WORKDIR/output.log truncate --size=0 $WORKDIR/output.log
source $i source $i
done done

View File

@ -17,7 +17,7 @@ if [[ ! $whereami =~ test-buildah-v ]]; then
fi fi
# FIXME: check that git repo is buildah # FIXME: check that git repo is buildah
git remote -v | grep -q [BUILDAHREPO] \ git remote -v | grep -q '[BUILDAHREPO]' \
|| die "This does not look like a buildah repo (git remote -v)" || die "This does not look like a buildah repo (git remote -v)"
# We could do the commit automatically, but it's prudent to require human # We could do the commit automatically, but it's prudent to require human

View File

@ -64,7 +64,7 @@ function is() {
local expect=$2 local expect=$2
local testname=$3 local testname=$3
if [[ $actual = $expect ]]; then if [[ "$actual" = "$expect" ]]; then
# On success, include expected value; this helps readers understand # On success, include expected value; this helps readers understand
_show_ok 1 "$testname=$expect" _show_ok 1 "$testname=$expect"
return return
@ -303,12 +303,12 @@ n_tests=0
# We aren't really TAP 13; this helps logformatter recognize our output as BATS # We aren't really TAP 13; this helps logformatter recognize our output as BATS
echo "TAP version 13" echo "TAP version 13"
for t in ${tests_to_run[@]}; do for t in "${tests_to_run[@]}"; do
testdir="$(dirname $t)" testdir="$(dirname $t)"
testname="$(basename $testdir)" testname="$(basename $testdir)"
if [ -e $test_dir/SKIP ]; then if [ -e $test_dir/SKIP ]; then
local reason="$(<$test_dir/SKIP)" reason="$(<$test_dir/SKIP)"
if [ -n "$reason" ]; then if [ -n "$reason" ]; then
reason=" - $reason" reason=" - $reason"
fi fi

View File

@ -121,7 +121,7 @@ function check_help() {
# Exceptions: these commands don't work rootless # Exceptions: these commands don't work rootless
if is_rootless; then if is_rootless; then
# "pause is not supported for rootless containers" # "pause is not supported for rootless containers"
if [ "$cmd" = "pause" -o "$cmd" = "unpause" ]; then if [[ "$cmd" = "pause" ]] || [[ "$cmd" = "unpause" ]]; then
continue continue
fi fi
# "network rm" too # "network rm" too
@ -162,17 +162,17 @@ function check_help() {
# Any command that takes subcommands, prints its help and errors if called # Any command that takes subcommands, prints its help and errors if called
# without one. # without one.
dprint "podman $@" dprint "podman $*"
run_podman '?' "$@" run_podman '?' "$@"
is "$status" 125 "'podman $*' without any subcommand - exit status" is "$status" 125 "'podman $*' without any subcommand - exit status"
is "$output" ".*Usage:.*Error: missing command '.*$@ COMMAND'" \ is "$output" ".*Usage:.*Error: missing command '.*$* COMMAND'" \
"'podman $*' without any subcommand - expected error message" "'podman $*' without any subcommand - expected error message"
# Assume that 'NoSuchCommand' is not a command # Assume that 'NoSuchCommand' is not a command
dprint "podman $@ NoSuchCommand" dprint "podman $* NoSuchCommand"
run_podman '?' "$@" NoSuchCommand run_podman '?' "$@" NoSuchCommand
is "$status" 125 "'podman $* NoSuchCommand' - exit status" is "$status" 125 "'podman $* NoSuchCommand' - exit status"
is "$output" "Error: unrecognized command .*$@ NoSuchCommand" \ is "$output" "Error: unrecognized command .*$* NoSuchCommand" \
"'podman $* NoSuchCommand' - expected error message" "'podman $* NoSuchCommand' - expected error message"
# This can happen if the output of --help changes, such as between # This can happen if the output of --help changes, such as between

View File

@ -436,7 +436,7 @@ load helpers
run_podman cp cpcontainer:$src $destdir$dest run_podman cp cpcontainer:$src $destdir$dest
is "$(< $destdir$dest_fullname/containerfile0)" "${randomcontent[0]}" "$description" is "$(< $destdir$dest_fullname/containerfile0)" "${randomcontent[0]}" "$description"
is "$(< $destdir$dest_fullname/containerfile1)" "${randomcontent[1]}" "$description" is "$(< $destdir$dest_fullname/containerfile1)" "${randomcontent[1]}" "$description"
rm -rf $destdir/* rm -rf ${destdir:?}/*
done < <(parse_table "$tests") done < <(parse_table "$tests")
run_podman kill cpcontainer run_podman kill cpcontainer
run_podman rm -t 0 -f cpcontainer run_podman rm -t 0 -f cpcontainer
@ -456,7 +456,7 @@ load helpers
run_podman cp cpcontainer:$src $destdir$dest run_podman cp cpcontainer:$src $destdir$dest
is "$(< $destdir$dest_fullname/containerfile0)" "${randomcontent[0]}" "$description" is "$(< $destdir$dest_fullname/containerfile0)" "${randomcontent[0]}" "$description"
is "$(< $destdir$dest_fullname/containerfile1)" "${randomcontent[1]}" "$description" is "$(< $destdir$dest_fullname/containerfile1)" "${randomcontent[1]}" "$description"
rm -rf $destdir/* rm -rf ${destdir:?}/*
done < <(parse_table "$tests") done < <(parse_table "$tests")
touch $destdir/testfile touch $destdir/testfile

View File

@ -541,7 +541,7 @@ Labels.$label_name | $label_value
this-file-does-not-match-anything-in-ignore-file this-file-does-not-match-anything-in-ignore-file
comment comment
) )
for f in ${files[@]}; do for f in "${files[@]}"; do
# The magic '##-' strips off the '-' prefix # The magic '##-' strips off the '-' prefix
echo "$f" > $tmpdir/${f##-} echo "$f" > $tmpdir/${f##-}
done done

View File

@ -315,11 +315,11 @@ EOF
# List available volumes for pruning after using 1,2,3 # List available volumes for pruning after using 1,2,3
run_podman volume prune <<< N run_podman volume prune <<< N
is "$(echo $(sort <<<${lines[@]:1:3}))" "${v[4]} ${v[5]} ${v[6]}" "volume prune, with 1,2,3 in use, lists 4,5,6" is "$(echo $(sort <<<${lines[*]:1:3}))" "${v[4]} ${v[5]} ${v[6]}" "volume prune, with 1,2,3 in use, lists 4,5,6"
# List available volumes for pruning after using 1,2,3 and filtering; see #8913 # List available volumes for pruning after using 1,2,3 and filtering; see #8913
run_podman volume prune --filter label=mylabel <<< N run_podman volume prune --filter label=mylabel <<< N
is "$(echo $(sort <<<${lines[@]:1:2}))" "${v[5]} ${v[6]}" "volume prune, with 1,2,3 in use and 4 filtered out, lists 5,6" is "$(echo $(sort <<<${lines[*]:1:2}))" "${v[5]} ${v[6]}" "volume prune, with 1,2,3 in use and 4 filtered out, lists 5,6"
# prune should remove v4 # prune should remove v4
run_podman volume prune --force run_podman volume prune --force

View File

@ -119,7 +119,7 @@ EOF
# Some of the above may not exist on our host. Find only the ones that do. # Some of the above may not exist on our host. Find only the ones that do.
local -a subset=() local -a subset=()
for mp in ${mps[@]}; do for mp in "${mps[@]}"; do
if [ -e $mp ]; then if [ -e $mp ]; then
subset+=($mp) subset+=($mp)
fi fi
@ -128,7 +128,7 @@ EOF
# Run 'stat' on all the files, plus /dev/null. Get path, file type, # Run 'stat' on all the files, plus /dev/null. Get path, file type,
# number of links, major, and minor (see below for why). Do it all # number of links, major, and minor (see below for why). Do it all
# in one go, to avoid multiple podman-runs # in one go, to avoid multiple podman-runs
run_podman '?' run --rm $IMAGE stat -c'%n:%F:%h:%T:%t' /dev/null ${subset[@]} run_podman '?' run --rm $IMAGE stat -c'%n:%F:%h:%T:%t' /dev/null "${subset[@]}"
assert $status -le 1 "stat exit status: expected 0 or 1" assert $status -le 1 "stat exit status: expected 0 or 1"
local devnull= local devnull=