summaryrefslogtreecommitdiff
path: root/update-openssh-known-hosts
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2021-07-19 13:33:32 +0200
committerTimo Weingärtner <timo@tiwe.de>2021-07-19 13:33:32 +0200
commit265011411069c0c26dd693f714a43a6c7e6ad9ea (patch)
tree3a158cb4e5b0961299e44854d558340ddd83d265 /update-openssh-known-hosts
parent0b161b76dac289f4b7100916bac27961aed88120 (diff)
downloadopenssh-known-hosts-265011411069c0c26dd693f714a43a6c7e6ad9ea.tar.gz
use bash arrays in path_search()
Diffstat (limited to 'update-openssh-known-hosts')
-rwxr-xr-xupdate-openssh-known-hosts13
1 files changed, 6 insertions, 7 deletions
diff --git a/update-openssh-known-hosts b/update-openssh-known-hosts
index ef897aa..c8f7e39 100755
--- a/update-openssh-known-hosts
+++ b/update-openssh-known-hosts
@@ -28,22 +28,21 @@ OUTFILE=${OUTFILE:-/var/lib/openssh-known-hosts/ssh_known_hosts}
readonly CONFDIR PLUGIN_PATH CACHEDIR LOCK OUTFILE
path_search () {
- search="$1"
- shift
- local IFS
- IFS=:
- set -- $@
+ local search=$1
+ local -a pathlist
+ IFS=: read -ra pathlist <<< "$2"
+
if [[ ${search} =~ / ]]; then
echo "${search}"
return 0
fi
- for path; do
+ for path in "${pathlist[@]}"; do
if [ -f "${path}/${search}" ]; then
echo "${path}/${search}"
return 0
fi
done
- echo "'${search}' not found in '$*'!" >&2
+ echo "'${search}' not found in '$2'!" >&2
exit 127
}