aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-05 11:15:44 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-05 11:15:44 +1200
commitd8dc759e45a991bb0d254cfe50f6efdbdaffd070 (patch)
tree40487b867234544fdd930842c691d205d40806e1
parentRemove redundant arg check (diff)
downloaddotfiles-d8dc759e45a991bb0d254cfe50f6efdbdaffd070.tar.gz
dotfiles-d8dc759e45a991bb0d254cfe50f6efdbdaffd070.zip
Don't allow dirs with : in name
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03> "Since <colon> is a separator in this context, directory names that might be used in PATH should not include a <colon> character."
-rw-r--r--bash/bashrc.d/path.bash10
1 files changed, 10 insertions, 0 deletions
diff --git a/bash/bashrc.d/path.bash b/bash/bashrc.d/path.bash
index 658d41a9..961e84cd 100644
--- a/bash/bashrc.d/path.bash
+++ b/bash/bashrc.d/path.bash
@@ -57,6 +57,11 @@ path() {
"$FUNCNAME" "$dir" >&2
return 1
fi
+ if [[ $dir == *:* ]] ; then
+ printf 'bash: %s: Cannot add insert directory %s with colon in name\n' \
+ "$FUNCNAME" "$dir" >&2
+ return 1
+ fi
if path check "$dir" ; then
printf 'bash: %s: %s already in PATH\n' \
"$FUNCNAME" "$dir" >&2
@@ -81,6 +86,11 @@ path() {
"$FUNCNAME" "$dir" >&2
return 1
fi
+ if [[ $dir == *:* ]] ; then
+ printf 'bash: %s: Cannot append directory %s with colon in name\n' \
+ "$FUNCNAME" "$dir" >&2
+ return 1
+ fi
if path check "$dir" ; then
printf 'bash: %s: %s already in PATH\n' \
"$FUNCNAME" "$dir" >&2