diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-04-29 17:35:36 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-04-29 17:35:36 +1200 |
commit | 62c8407e2d23c52e71f099de920ec91fce3f622b (patch) | |
tree | 1871b53141ec0c8f6f3ca2a9a57638ac0fb3e24b | |
parent | Only print line if at least one arg (diff) | |
download | dotfiles-62c8407e2d23c52e71f099de920ec91fce3f622b.tar.gz dotfiles-62c8407e2d23c52e71f099de920ec91fce3f622b.zip |
Use FUNCNAME rather than hardcoding helper funcs
-rw-r--r-- | bash/bashrc.d/bd.bash | 3 | ||||
-rw-r--r-- | bash/bashrc.d/cd.bash | 3 | ||||
-rw-r--r-- | bash/bashrc.d/cf.bash | 9 | ||||
-rw-r--r-- | bash/bashrc.d/pd.bash | 6 | ||||
-rw-r--r-- | bash/bashrc.d/scp.bash | 3 | ||||
-rw-r--r-- | bash/bashrc.d/scr.bash | 3 |
6 files changed, 18 insertions, 9 deletions
diff --git a/bash/bashrc.d/bd.bash b/bash/bashrc.d/bd.bash index 8df18907..e856fc40 100644 --- a/bash/bashrc.d/bd.bash +++ b/bash/bashrc.d/bd.bash @@ -12,7 +12,8 @@ bd() { if [[ -d $dir ]] ; then builtin cd -- "$dir" else - printf 'bash: No dir found in PWD named %s\n' "$1" >&2 + printf 'bash: %s: No dir found in PWD named %s\n' \ + "$FUNCNAME" "$1" >&2 return 1 fi } diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash index a851752b..908f6822 100644 --- a/bash/bashrc.d/cd.bash +++ b/bash/bashrc.d/cd.bash @@ -22,7 +22,8 @@ cd() { if [[ $PWD == *"$1"* ]] ; then builtin cd "${opts[@]}" -- "${PWD/$1/$2}" else - printf 'bash: cd: could not replace substring\n' >&2 + printf 'bash: %s: could not replace substring\n' \ + "$FUNCNAME" >&2 return 1 fi else diff --git a/bash/bashrc.d/cf.bash b/bash/bashrc.d/cf.bash index 707f2a76..be66ecea 100644 --- a/bash/bashrc.d/cf.bash +++ b/bash/bashrc.d/cf.bash @@ -7,13 +7,16 @@ cf() { # Error conditions if [[ ! -e $dir ]] ; then - printf 'bash: cf: %s does not exist\n' "$dir" >&2 + printf 'bash: %s: %s does not exist\n' \ + "$FUNCNAME" "$dir" >&2 return 1 elif [[ ! -d $dir ]] ; then - printf 'bash: cf: %s is not a directory\n' "$dir" >&2 + printf 'bash: %s: %s is not a directory\n' \ + "$FUNCNAME" "$dir" >&2 return 1 elif [[ ! -r $dir ]] ; then - printf 'bash: cf: %s is not readable\n' "$dir" >&2 + printf 'bash: %s: %s is not readable\n' \ + "$FUNCNAME" "$dir" >&2 return 1 fi diff --git a/bash/bashrc.d/pd.bash b/bash/bashrc.d/pd.bash index 346816a1..86a0fb18 100644 --- a/bash/bashrc.d/pd.bash +++ b/bash/bashrc.d/pd.bash @@ -31,14 +31,16 @@ pd() { target=${target%/*} ;; *) - printf 'bash: pd: too many arguments\n' >&2 + printf 'bash: %s: too many arguments\n' \ + "$FUNCNAME" >&2 return 1 ;; esac if [[ $target ]] ; then builtin cd "${opts[@]}" -- "$target" else - printf 'bash: pd: error calculating parent directory\n' >&2 + printf 'bash: %s: error calculating parent directory\n' \ + "$FUNCNAME" >&2 return 1 fi } diff --git a/bash/bashrc.d/scp.bash b/bash/bashrc.d/scp.bash index 3d5fc1dd..0d97d283 100644 --- a/bash/bashrc.d/scp.bash +++ b/bash/bashrc.d/scp.bash @@ -1,7 +1,8 @@ # Wrap scp to check for missing colons scp() { if (($# >= 2)) && [[ $* != *:* ]] ; then - printf 'scp: Missing colon, probably an error\n' >&2 + printf 'bash: %s: Missing colon, probably an error\n' \ + "$FUNCNAME" >&2 return 1 fi command scp "$@" diff --git a/bash/bashrc.d/scr.bash b/bash/bashrc.d/scr.bash index b7a49b14..82d3fb5e 100644 --- a/bash/bashrc.d/scr.bash +++ b/bash/bashrc.d/scr.bash @@ -5,7 +5,8 @@ scr() { if (($# <= 1)) ; then pushd -- "$(mktemp -dt "${1:-scr}".XXXXX)" else - printf 'bash: scr: too many arguments\n' >&2 + printf 'bash: %s: too many arguments\n' \ + "$FUNCNAME" >&2 return 1 fi } |