diff options
Diffstat (limited to 'bash/bashrc.d/hgrep.bash')
-rw-r--r-- | bash/bashrc.d/hgrep.bash | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bash/bashrc.d/hgrep.bash b/bash/bashrc.d/hgrep.bash index 855fbcc8..e5a5d4c9 100644 --- a/bash/bashrc.d/hgrep.bash +++ b/bash/bashrc.d/hgrep.bash @@ -4,5 +4,13 @@ # $ history | grep PATTERN # hgrep() { - grep "${@:?}" "${HISTFILE:?}" + if ! (($#)) ; then + printf >&2 '%s: Need a pattern\n' "$FUNCNAME" + exit 2 + fi + if ! [[ $HISTFILE ]] ; then + printf >&2 '%s: No HISTFILE\n' "$FUNCNAME" + exit 2 + fi + grep "$@" "$HISTFILE" } |