logo

gemini-space

What lives at gemini://hacktivis.me/ git clone https://hacktivis.me/git/gemini-space.git
commit: d3ba724749b682b12cf72f34555dad5e1dc12c6e
parent 64474aa40c9dab64ebdc115b0fef5b82d37a4a13
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  4 Nov 2021 00:31:42 +0100

server.sh: Fix most shellcheck warnings

Diffstat:

Mserver.sh11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/server.sh b/server.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC1017 # Copyright 2020-2021 Haelwenn (lanodan) Monnier <contact+gemini@hacktivis.me> # Distributed under the terms of the GNU Affero General Public License version 3 @@ -40,7 +41,7 @@ query="${query//%20/ }" path="$GEMDIR/${query//\?*}" status="--" -if echo $path | egrep -q '.gmi$' +if echo "$path" | grep -Eq '.gmi$' then mime="text/gemini; charset=utf-8" else @@ -49,11 +50,11 @@ fi if [ -r "$path" -a -f "$path" ] then - if echo $query | egrep -q '/cgi-bin/' + if echo "$query" | grep -Eq '/cgi-bin/' then if [ -x "$path" -a -f "$path" ] then - if echo $query | egrep -q '\?' + if echo "$query" | grep -Eq '\?' then bubblewrap "./${query//\?*}" "${query//*\?}" else @@ -71,7 +72,7 @@ then fi elif [ -r "$path" -a -d "$path" ] then - if echo $path | egrep -q '/$' + if echo "$path" | grep -Eq '/$' then if [ -r "$path/index.gmi" -a -f "$path/index.gmi" ] then @@ -82,7 +83,7 @@ then status="20" printf '20 text/gemini; charset=utf-8\r\n' printf '# Index of %s\n' "$query" - ls "${path}" | sed -e 's/ /%20/g' -e "s/^/=> /" 2>/dev/null + cd "$path" && find . -mindepth 1 -maxdepth 1 | sed -e 's; ;%20;g' -e "s;^\./;=> ;" 2>/dev/null fi else status="30"