From d8dc759e45a991bb0d254cfe50f6efdbdaffd070 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 5 Jun 2015 11:15:44 +1200 Subject: Don't allow dirs with : in name "Since is a separator in this context, directory names that might be used in PATH should not include a character." --- bash/bashrc.d/path.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.3