From fdeee8ccf213f7e9f74b81abc7f0f96b28b35a6d Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sun, 17 Feb 2019 09:06:50 +0000 Subject: minor edits on variable quoting --- README.md | 10 ++++++++-- gophed | 18 +++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7749307..5ce918e 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,14 @@ or equivalently: ./v gopher://kalos.mine.nu ``` -This command will download the corresponding resource, and print it on -output with line numbers. An excerpt is reported below: +This command will download the corresponding resource. If you want to +print it on output with line numbers, just give the command: + +``` +%n [ENTER] +``` + +and you should see something like: ``` ... diff --git a/gophed b/gophed index 64d9b16..eaf0345 100755 --- a/gophed +++ b/gophed @@ -32,16 +32,16 @@ usage() { } goto_url(){ - URL="$(echo $1 | sed 's,gopher://,,g')" + URL="$(echo "$1" | sed 's,gopher://,,g')" hostport=$(echo "$URL" | cut -d "/" -f 1) - host="$(echo $hostport | cut -d ":" -f 1)" - port="$(echo $hostport | cut -s -d ":" -f 2)" + host="$(echo "$hostport" | cut -d ":" -f 1)" + port="$(echo "$hostport" | cut -s -d ":" -f 2)" [ -z "$port" ] && port='70' type=$(echo "$URL" | cut -s -d "/" -f 2) [ -z "$type" ] && { type='1' sel="/" - go $sel $host $port + go "$sel" "$host" "$port" return } [ -n "${type#?}" ] && echo "Invalid Gopher URL" >&2 && exit 1 @@ -49,12 +49,12 @@ goto_url(){ type="$(echo $type | sed -n '/^[0-9ITghis+]$/p')" [ -z "${type}" ] && echo "Invalid Gopher URL" >&2 && exit 1 sel=/$(echo "$URL" | cut -s -d "/" -f 3-) - go $sel $host $port + go "$sel" "$host" "$port" } -trap cleanup INT QUIT HUP KILL ABRT TERM +trap cleanup INT QUIT HUP ABRT TERM [ "$#" -lt 1 ] || [ "$1" = "-h" ] && usage @@ -72,7 +72,7 @@ if [ "$script_name" = "gophed" ] || [ "$script_name" = "v" ]; then sel="$(printf '%s' "$1" | sed -r 's:/:+:g')" TMPFILE="$(mktemp "/tmp/gophed_${2}_${sel}_$3.XXXXXXXXXXXXXXXXXXX")" goto_url "$1" > "$TMPFILE" - while read line; do echo $line; done | ed -p "$PROMPT" "$TMPFILE" + while read -r line; do echo "$line"; done | ed -p "$PROMPT" "$TMPFILE" cleanup exit 0 fi @@ -87,7 +87,7 @@ if [ "$script_name" = "g" ] || [ "$script_name" = "d" ]; then SEL="$(printf '%s' "$RESOURCE" | sed -r 's:/:+:g')" TMPFILE="$(mktemp "/tmp/gophed_${HOST}_${SEL}_$PORT.XXXXXXXXXXXXXXXXXXX")" go "$RESOURCE" "$HOST" "$PORT" > "$TMPFILE" - while read line; do echo $line; done | ed -p "$PROMPT" "$TMPFILE" + while read -r line; do echo "$line"; done | ed -p "$PROMPT" "$TMPFILE" fi if [ "$script_name" = "d" ]; then DIR_RESOURCE="$(dirname "$RESOURCE")" @@ -98,7 +98,7 @@ if [ "$script_name" = "g" ] || [ "$script_name" = "d" ]; then cleanup exit 0 fi -printf '%s: command not found\n' "$scriptname" +printf '%s: command not found\n' "$script_name" cleanup -- cgit v1.2.3