fix SRV_ARGS should be declared as an array

This commit is contained in:
Emile Clark-Boman 2025-08-06 19:01:06 +10:00
parent 1de8d1d791
commit f4f8e15bf1

14
serve
View file

@ -9,7 +9,7 @@ PORT="8000" # bind port
WEBROOT="www" # root web directory WEBROOT="www" # root web directory
USE_INDEX=true USE_INDEX=true
NO_CACHE=true NO_CACHE=true
SRV_ARGS="" declare -a SRV_ARGS=()
SCSS_PATH="$WEBROOT/scss" SCSS_PATH="$WEBROOT/scss"
CSS_PATH="$WEBROOT/css" CSS_PATH="$WEBROOT/css"
@ -21,21 +21,21 @@ function watch_scss {
sass --watch "$SCSS_PATH:$CSS_PATH" sass --watch "$SCSS_PATH:$CSS_PATH"
} }
function host ( function host {
local args="$SRV_ARGS" local args=$@
# Apply Flags # Apply Flags
if [[ "$NO_CACHE" == true ]]; then if [[ "$NO_CACHE" == true ]]; then
args+=" --nocache" args+=("--nocache")
fi fi
if [[ "$USE_INDEX" == true ]]; then if [[ "$USE_INDEX" == true ]]; then
args+=" --index" args+=("--index")
fi fi
# Apply Options # Apply Options
args+=" --ip \"$ADDR\" --port \"$PORT\"" args+=(--ip "$ADDR" --port "$PORT")
simple-http-server $args $@ -- "$WEBROOT" simple-http-server $args $@ -- "$WEBROOT"
) }
set -ueo pipefail set -ueo pipefail
set -x set -x