From 61fcec09f7f5d1361d763a35bcd3f966ed0aef88 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 14 Apr 2018 19:49:31 +0200 Subject: [PATCH] gopher.sh: allow forced type specifiers --- gopher.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gopher.sh b/gopher.sh index 91a02bb..0ec852b 100755 --- a/gopher.sh +++ b/gopher.sh @@ -29,12 +29,20 @@ SELECTOR="$2" 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 + + # 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 @@ -70,8 +78,6 @@ else INVERT= fi -PREFIX="[0-9hIg+]" - # $0 [FILE] (dialog) # Display a gopher menu for the given resource cat_menu() { -- 2.27.0