summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-01-23 23:20:43 +0000
committerKatolaZ <katolaz@freaknet.org>2019-01-23 23:23:09 +0000
commitda1b7d16405eca03fd31dcbad33485b078dd7125 (patch)
treecf32f1be09e1f0b8a02f8fcfd25d23843707fed5
parentbdfe168ec85a774c585d6153ef98f6bd789a1b3c (diff)
rename commands & check for empty argument list
-rwxr-xr-xgophed16
1 files changed, 10 insertions, 6 deletions
diff --git a/gophed b/gophed
index 1febbe7..a6d7561 100755
--- a/gophed
+++ b/gophed
@@ -19,20 +19,24 @@ usage() {
printf " $0 -h\n"
printf "\n"
printf "In a gopher page, just type:\n"
- printf " !./visit %% LINE\n"
+ printf " !./g %% LINE\n"
printf "to visit the resource at LINE, or:\n"
- printf " !./dl %% LINE\n"
+ printf " !./d %% LINE\n"
printf "to download the resource at LINE\n\n"
exit 0
}
trap cleanup INT QUIT HUP KILL ABRT TERM
+if [ $# -lt 1 ]; then
+ usage
+fi
+
if [ "$1" = "-h" ]; then usage; fi
if [ "$1" = "-i" ]; then
- ln -s $0 visit
- ln -s $0 dl
+ ln -s $0 g
+ ln -s $0 d
exit 0
fi
@@ -44,7 +48,7 @@ if [ "${script_name}" = "gophed" ]; then
go "$1" "$2" "$3" > $TMPFILE
cat show - show | ed $TMPFILE
fi
-if [ "${script_name}" = "visit" ]; then
+if [ "${script_name}" = "g" ]; then
LINE=$(awk "{if (NR == $2) print \$0;}" $1)
RESOURCE=$(echo "$LINE" | cut -d ' ' -f 2)
HOST=$(echo "$LINE" | cut -d ' ' -f 3)
@@ -54,7 +58,7 @@ if [ "${script_name}" = "visit" ]; then
go "$RESOURCE" "$HOST" "$PORT" > $TMPFILE
cat show - show | ed $TMPFILE
fi
-if [ "${script_name}" = "dl" ]; then
+if [ "${script_name}" = "d" ]; then
LINE=$(awk "{if (NR == $2) print \$0;}" $1)
RESOURCE=$(echo "$LINE" | cut -d ' ' -f 2)
HOST=$(echo "$LINE" | cut -d ' ' -f 3)