diff options
-rw-r--r-- | bash/bashrc.d/hgrep.bash | 10 | ||||
-rwxr-xr-x | bin/jfcd | 4 | ||||
-rwxr-xr-x | bin/rfcf | 9 | ||||
-rwxr-xr-x | bin/rfcr | 9 |
4 files changed, 27 insertions, 5 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" } @@ -18,8 +18,8 @@ inw() { logger --tag "$self" } -# Drectory to check is first and only argument; move into it -cd -- "${1:?}" || exit +# Directory to check is first and only argument; defaults to current directory +cd -- "${1:-.}" || exit # Run a while loop over inotifywait(1) calls, running jfc(1) on the working # directory @@ -1,5 +1,12 @@ #!/bin/sh +# Figure out RFC number +self=rfcf +if ! [ "$1" ] ; then + printf >&2 '%s: Need an RFC number\n' "$self" + exit 2 +fi +rn=$1 + # Retrieve the RFC with curl(1) -rn=${1?Need an RFC number} curl https://tools.ietf.org/rfc/rfc"$rn".txt @@ -1,7 +1,14 @@ #!/bin/sh +# Figure out RFC number +self=rfcr +if ! [ "$1" ] ; then + printf >&2 '%s: Need an RFC number\n' "$self" + exit 2 +fi +rn=$1 + # Retrieve the RFC with rfcf(1) -rn=${1?Need an RFC number} rfcf "$rn" | # Pipe it through rfct(1) to format it as text |