aboutsummaryrefslogtreecommitdiffstats
path: root/tools/fs_mkdir.sh
blob: f2e9b277af11254507e805f94dd481fe642d740a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
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() {
  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