diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-01-03 16:45:37 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-01-19 09:53:47 +0100 |
commit | f6488bbd0dc8e360bcfae952f8be78f82e57bf63 (patch) | |
tree | 112df4070069d98ee13fa31f93439c52c0ec8345 | |
parent | df4763fad0288736b8df545ea78617bae5c73f2d (diff) | |
download | ptxdist-f6488bbd0dc8e360bcfae952f8be78f82e57bf63.tar.gz ptxdist-f6488bbd0dc8e360bcfae952f8be78f82e57bf63.tar.xz |
[libptxdist] add ptxd_in_path to find files in ":" separated paths
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | scripts/libptxdist.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh index 121307f58..fe5eb4f1f 100644 --- a/scripts/libptxdist.sh +++ b/scripts/libptxdist.sh @@ -462,6 +462,28 @@ ptxd_get_path() { } export -f ptxd_get_path +# +# ptxd_in_path - look for files and/or dirs +# +# $1 variable name with paths separated by ":" +# $2 filename to find within these paths +# +# return: +# 0 if files/dirs are found +# 1 if no files/dirs are found +# +# array "ptxd_reply" containing the found files/dirs +# +ptxd_in_path() { + local orig_IFS="${IFS}" + IFS=: + local -a paths + paths=( ${!1} ) + IFS="${orig_IFS}" + paths=( "${paths[@]/%//${2}}" ) + ptxd_get_path "${paths[@]}" +} +export -f ptxd_in_path # # convert a relative or absolute path into an absolute path |