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