aboutsummaryrefslogtreecommitdiffstats
path: root/tools/fs_mkdir.sh
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2026-02-03 16:54:42 +0100
committerLeonard Kugis <leonard@kug.is>2026-02-03 16:54:42 +0100
commit27e319f8d1e3a0e8f2db79f62d451768b11d62a3 (patch)
tree501423803651a8442b81ecb52177dc524880ccfa /tools/fs_mkdir.sh
parent808af93158fce5c5197a646a9148191840800621 (diff)
downloadllm-functions-docker-27e319f8d1e3a0e8f2db79f62d451768b11d62a3.tar.gz
Refined tool return error codes.
Now they all return with exit 0 and error messages instead. This prevents early query abortion on fatal errors.
Diffstat (limited to 'tools/fs_mkdir.sh')
-rwxr-xr-xtools/fs_mkdir.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/fs_mkdir.sh b/tools/fs_mkdir.sh
index a91954f..f2e9b27 100755
--- a/tools/fs_mkdir.sh
+++ b/tools/fs_mkdir.sh
@@ -1,15 +1,30 @@
#!/usr/bin/env bash
-set -e
+set -uo pipefail
# @describe Create a new directory at the specified path.
-
# @option --path! The path of the directory to create
-
# @env LLM_OUTPUT=/dev/stdout The output path
+OUT="${LLM_OUTPUT:-/dev/stdout}"
+
+err() {
+ echo "ERROR: $*" >> "$OUT"
+ exit 0
+}
+
main() {
- mkdir -p "$argc_path"
- echo "Directory created: $argc_path" >> "$LLM_OUTPUT"
+ path="${argc_path:-}"
+ [[ -z "$path" ]] && err "missing --path"
+
+ if ! mkdir -p "$path" 2>/tmp/fs_mkdir.err; then
+ msg="$(cat /tmp/fs_mkdir.err 2>/dev/null || true)"
+ err "mkdir failed for $path: ${msg:-unknown error}"
+ fi
+
+ echo "Directory created: $path" >> "$OUT"
+ exit 0
}
eval "$(argc --argc-eval "$0" "$@")"
+main
+