aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash/bashrc.d/hgrep.bash10
-rwxr-xr-xbin/jfcd4
-rwxr-xr-xbin/rfcf9
-rwxr-xr-xbin/rfcr9
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"
}
diff --git a/bin/jfcd b/bin/jfcd
index 63fd185c..87b669fd 100755
--- a/bin/jfcd
+++ b/bin/jfcd
@@ -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
diff --git a/bin/rfcf b/bin/rfcf
index 48cc2d43..72c076a9 100755
--- a/bin/rfcf
+++ b/bin/rfcf
@@ -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
diff --git a/bin/rfcr b/bin/rfcr
index a11457a9..74488c8c 100755
--- a/bin/rfcr
+++ b/bin/rfcr
@@ -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