git://git.nikiroo.be
/
gofetch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a1fd156
)
gopher.sh: allow forced type specifiers
author
Niki Roo
<niki@nikiroo.be>
Sat, 14 Apr 2018 17:49:31 +0000
(19:49 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Sat, 14 Apr 2018 17:49:31 +0000
(19:49 +0200)
gopher.sh
patch
|
blob
|
blame
|
history
diff --git
a/gopher.sh
b/gopher.sh
index 91a02bb497360e3e3cfe32741685062dc901c56d..0ec852b0cf9f1dbe15def858d60f295ac1f756a7 100755
(executable)
--- a/
gopher.sh
+++ b/
gopher.sh
@@
-29,12
+29,20
@@
SELECTOR="$2"
PORT="$3"
MODE="$4"
PORT="$3"
MODE="$4"
+PREFIX="[0-9hIg+]"
+
# Defaults:
[ "$PORT" = "" ] && PORT=70
if [ "$MODE" = "" ]; then
# "" or dir-like selector? -> 1 ; if not -> 0
echo "$SELECTOR" | grep "/$" >/dev/null && MODE=1 || MODE=0
[ "$SELECTOR" = "" ] && MODE=1
# Defaults:
[ "$PORT" = "" ] && PORT=70
if [ "$MODE" = "" ]; then
# "" or dir-like selector? -> 1 ; if not -> 0
echo "$SELECTOR" | grep "/$" >/dev/null && MODE=1 || MODE=0
[ "$SELECTOR" = "" ] && MODE=1
+
+ # check explicit modes:
+ if echo "$SELECTOR" | grep "^/\($PREFIX\|download\)/" >/dev/null; then
+ MODE="`echo "$SELECTOR" | cut -f2 -d/`"
+ SELECTOR="`echo "$SELECTOR" | sed 's:^/[^/]*/::'`"
+ fi
fi
if [ "$SERVER" = "" ]; then
fi
if [ "$SERVER" = "" ]; then
@@
-70,8
+78,6
@@
else
INVERT=
fi
INVERT=
fi
-PREFIX="[0-9hIg+]"
-
# $0 [FILE] (dialog)
# Display a gopher menu for the given resource
cat_menu() {
# $0 [FILE] (dialog)
# Display a gopher menu for the given resource
cat_menu() {