From: Niki Roo Date: Sat, 14 Apr 2018 17:49:31 +0000 (+0200) Subject: gopher.sh: allow forced type specifiers X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=61fcec09f7f5d1361d763a35bcd3f966ed0aef88;p=gofetch.git gopher.sh: allow forced type specifiers --- 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() {