Christian Couder <[email protected]> writes:
> +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.
> +
> + 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.
> +
> + shift
> +done
> +
> +case "$REQUEST_METHOD" in
> + POST)
Likewise.
> + 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