From 265011411069c0c26dd693f714a43a6c7e6ad9ea Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Mon, 19 Jul 2021 13:33:32 +0200 Subject: use bash arrays in path_search() --- update-openssh-known-hosts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'update-openssh-known-hosts') 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 } -- cgit v1.2.3