Re: [PATCH v5 19/40] lib-httpd: add upload.sh
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 3, 2017, 20:07 UTC
- Message-ID
- <xmqq3798xvns.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170803091926.1755-20-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 9 quoted lines
> +OLDIFS="$IFS"
> +IFS='&'
> +set -- $QUERY_STRING
> +IFS="$OLDIFS"
> +
> +while test $# -gt 0
> +do
> + key=${1%=*}
> + val=${1#*=}When you see that ${V%X*} and ${V#*X} appear in a pair for the same variable V and same delimiter X, it almost always indicates a bug waiting to happen.
What's the definition of "key" here? A member of known set of short tokens, all of which consists only of alphanumeric, or something? Even if you do not currently plan to deal with a value with '=' in it, it may be prudent to double '%' above (and do not double '#').
Style: indent your shell script with tabs.
Show 8 quoted lines
> + > + case "$key" in > + "sha1") sha1="$val" ;; > + "type") type="$val" ;; > + "size") size="$val" ;; > + "delete") delete=1 ;; > + *) echo >&2 "unknown key '$key'" ;; > + esac
Indent your shell script with tabs; case/esac and the labels used for each case arms all align at the same column.
Show 6 quoted lines
> + > + shift > +done > + > +case "$REQUEST_METHOD" in > + POST)
Likewise.
Show 16 quoted lines
> + if test "$delete" = "1" > + then > + rm -f "$FILES_DIR/$sha1-$size-$type" > + else > + mkdir -p "$FILES_DIR" > + cat >"$FILES_DIR/$sha1-$size-$type" > + fi > + > + echo 'Status: 204 No Content' > + echo > + ;; > + > + *) > + echo 'Status: 405 Method Not Allowed' > + echo > +esac