summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-07-01 00:04:05 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-07-01 00:04:05 -0600
commit720eb803375a1b31c766f1775fd13c4169ebcfe4 (patch)
tree9791fc19dc4add72169a4d4c36257442046cabd2
parentcb705f2a049a822d0c481dc849e70dfda4745408 (diff)
bash-arrays: the path_ls() example was leaking IFS. Thanks /u/Vaphell !
-rw-r--r--public/bash-arrays.md5
1 files changed, 3 insertions, 2 deletions
diff --git a/public/bash-arrays.md b/public/bash-arrays.md
index 23d90bb..e7f5842 100644
--- a/public/bash-arrays.md
+++ b/public/bash-arrays.md
@@ -348,8 +348,9 @@ an array is when you didn't want an array, but it's what you get
# Does not correctly handle programs with a newline in the name,
# as the output is newline-separated.
path_ls() {
- local dirs
- IFS=: dirs=($@) # The odd-ball time that it needs to be unquoted
+ local IFS dirs
+ IFS=:
+ dirs=($@) # The odd-ball time that it needs to be unquoted
find -L "${dirs[@]}" -maxdepth 1 -type f -executable \
-printf '%f\n' 2>/dev/null | sort -u
}