diff --git a/manage.sh b/manage.sh index ae7884e..01efd70 100755 --- a/manage.sh +++ b/manage.sh @@ -71,6 +71,10 @@ usage() { cat </dev/null)" || + die "invalid STACKS_DIR: $STACKS_DIR" + path="$target" + [[ "$path" == /* ]] || path="$STACKS_DIR/$path" + resolved="$(readlink -f -- "$path" 2>/dev/null)" || + die "stack folder not found: $original" + [[ -d "$resolved" ]] || die "stack folder not found: $original" + canonical="$(readlink -f -- "$root/$name" 2>/dev/null)" + [[ "$resolved" == "$canonical" ]] || + die "not a stack folder in $root: $original" + + target="$name" +} + # Set the maximum concurrency within each stage. max_parallel() { [[ $# -eq 1 ]] || die "max_parallel expects exactly one value" @@ -170,6 +210,7 @@ add_stage() { local stack local -n stages="$stages_name" local -n limits="$limits_name" + local -a normalized=() shift 3 if [[ "${1:-}" == "--parallel" ]]; then @@ -182,15 +223,17 @@ add_stage() { [[ $# -ge 1 ]] || die "$stage expects at least one stack" for stack in "$@"; do + normalize_target stack validate_name "stack" "$stack" contains "$stack" "${CONFIGURED_STACKS[@]}" && die "stack is assigned more than once: $stack" contains "$stack" "${EXCLUDED_STACKS[@]}" && die "stack is both assigned and excluded: $stack" CONFIGURED_STACKS+=("$stack") + normalized+=("$stack") done - stages+=("$*") + stages+=("${normalized[*]}") limits+=("$limit") } @@ -203,6 +246,7 @@ exclude() { local stack for stack in "$@"; do + normalize_target stack validate_name "stack" "$stack" contains "$stack" "${EXCLUDED_STACKS[@]}" && die "stack is excluded more than once: $stack" @@ -707,6 +751,10 @@ main() { ;; esac + if [[ -n "$TARGET" ]]; then + normalize_target TARGET + fi + load_config discover_stacks validate_config_stacks