Skip to content

Commit e420f24

Browse files
committed
build
1 parent 0875df7 commit e420f24

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,51 +4079,57 @@ get_file() {
40794079

40804080

40814081
test_file() {
4082-
local mode file real_file retcode
4082+
local mode file real_file
40834083
mode="${1}"
40844084
file="${2}"
4085-
## realpath needs to be able to access the path it checks
4085+
## 'realpath' needs to be able to access the path it checks.
40864086
real_file="$(root_cmd_loglevel="echo" dry_run=0 root_cmd realpath -- "${file}")"
4087-
## 'find' needs to start execution in a directory it can access
4087+
## 'find' needs to start execution in a directory it can access.
4088+
## But we are no longer using find. Maybe no longer needed.
40884089
pushd / >/dev/null
40894090
if [ "${mode}" = '-f' ]; then
4090-
if [ -z "$(run_as_target_user find "${real_file}" -maxdepth 0 -follow -type f 2>/dev/null)" ]; then
4091+
if run_as_target_user /usr/bin/test -f "${real_file}"; then
40914092
popd >/dev/null
4092-
return 1
4093+
return 0
40934094
else
40944095
popd >/dev/null
4095-
return 0
4096+
return 1
40964097
fi
40974098
elif [ "${mode}" = '-d' ]; then
4098-
if [ -z "$(run_as_target_user find "${real_file}" -maxdepth 0 -follow -type d 2>/dev/null)" ];
4099-
then
4099+
if run_as_target_user /usr/bin/test -d "${real_file}"; then
41004100
popd >/dev/null
4101-
return 1
4101+
return 0
41024102
else
41034103
popd >/dev/null
4104-
return 0
4104+
return 1
41054105
fi
41064106
elif [ "${mode}" = '-w' ]; then
4107-
run_as_target_user test -w "${real_file}"
4108-
retcode="$?"
4109-
popd >/dev/null
4110-
return "${retcode}"
4111-
elif [ "${mode}" = '-r' ]; then
4112-
run_as_target_user test -r "${real_file}"
4113-
retcode="$?"
4114-
popd >/dev/null
4115-
return "${retcode}"
4116-
elif [ "${mode}" = '-e' ]; then
4117-
if [ -z "$(run_as_target_user find "${real_file}" -maxdepth 0 2>/dev/null)" ];
4118-
then
4107+
if run_as_target_user /usr/bin/test -w "${real_file}"; then
4108+
popd >/dev/null
4109+
return 0
4110+
else
41194111
popd >/dev/null
41204112
return 1
4113+
fi
4114+
elif [ "${mode}" = '-r' ]; then
4115+
if run_as_target_user /usr/bin/test -r "${real_file}"; then
4116+
popd >/dev/null
4117+
return 0
41214118
else
4119+
popd >/dev/null
4120+
return 1
4121+
fi
4122+
elif [ "${mode}" = '-e' ]; then
4123+
if run_as_target_user /usr/bin/test -e "${real_file}"; then
41224124
popd >/dev/null
41234125
return 0
4126+
else
4127+
popd >/dev/null
4128+
return 1
41244129
fi
41254130
else
41264131
popd >/dev/null
4132+
die 1 "${underline}test_file:${nounderline} bug: Missing option."
41274133
return 1
41284134
fi
41294135
}

0 commit comments

Comments
 (0)