diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-05 11:15:44 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-05 11:15:44 +1200 |
commit | d8dc759e45a991bb0d254cfe50f6efdbdaffd070 (patch) | |
tree | 40487b867234544fdd930842c691d205d40806e1 | |
parent | Remove redundant arg check (diff) | |
download | dotfiles-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.bash | 10 |
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 |