summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2022-11-11 14:27:26 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2022-11-11 15:20:42 +0100
commit2a79322e003754025c912239bf4fc9e87f2d3455 (patch)
tree98cb9f5308ce6d40730ea9e44bfb6b54928562f9
parent9e3f90935bb6dbf135581e849c2dce271db8956d (diff)
downloadptxdist-2a79322e003754025c912239bf4fc9e87f2d3455.tar.gz
ptxdist-2a79322e003754025c912239bf4fc9e87f2d3455.tar.xz
ptxd_get_path: avoid calling 'ls'
ptxd_get_path is called a lot and doing this without executing another program is faster. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--scripts/libptxdist.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh
index ee0ba39d3..8d72cdf1b 100644
--- a/scripts/libptxdist.sh
+++ b/scripts/libptxdist.sh
@@ -399,13 +399,15 @@ export -f ptxd_get_alternative
# array "ptxd_reply" containing the found files/dirs
#
ptxd_get_path() {
+ local file
[ -n "${1}" ] || return
- local orig_IFS="${IFS}"
- IFS="
-"
- ptxd_reply=( $(command ls -f -d "${@}" 2>/dev/null) )
- IFS="${orig_IFS}"
+ ptxd_reply=()
+ for file in "${@}"; do
+ if [ -e "${file}" -o -h "${file}" ]; then
+ ptxd_reply[${#ptxd_reply[*]}]="${file}"
+ fi
+ done
[ ${#ptxd_reply[@]} -ne 0 ]
}