summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2018-11-15 07:41:12 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2018-11-15 07:41:15 +0100
commitf078fe59f8774c6229ad39d4df257c52216c3f54 (patch)
tree64503810f4a520df79901993a934fd371e49f32a /scripts
parent915f722c60f0804260fbd72388da17020bb17446 (diff)
downloadptxdist-f078fe59f8774c6229ad39d4df257c52216c3f54.tar.gz
ptxdist-f078fe59f8774c6229ad39d4df257c52216c3f54.tar.xz
ptxd_get_path_filtered: define new helper function
It is mostly the same as ptxd_get_path() but it filters out any results that are symlinks to /dev/null. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/libptxdist.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh
index 2e71aaf9d..5661cfa3a 100644
--- a/scripts/libptxdist.sh
+++ b/scripts/libptxdist.sh
@@ -377,6 +377,33 @@ ptxd_get_path() {
export -f ptxd_get_path
#
+# ptxd_get_path_fitered - look for files and/or dirs
+#
+# Like ptxd_get_path but skips paths that are symlinks to /dev/null
+#
+# return:
+# 0 if files/dirs are found
+# 1 if no files/dirs are found
+#
+# array "ptxd_reply" containing the found files/dirs
+#
+ptxd_get_path_filtered() {
+ ptxd_get_path "${@}" || return
+
+ set -- "${ptxd_reply[@]}"
+ ptxd_reply=()
+
+ while [ $# -gt 0 ]; do
+ if [ "$(readlink -f "${1}")" != /dev/null ]; then
+ ptxd_reply[${#ptxd_reply[@]}]="${1}"
+ fi
+ shift
+ done
+ [ ${#ptxd_reply[@]} -ne 0 ]
+}
+export -f ptxd_get_path_filtered
+
+#
# ptxd_in_path - look for files and/or dirs
#
# Note: the make implemenation in ptx/in-path must produce the same result.