blob: e667b0ec97d99b707d980ff37308d592066c2d8f (
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
31
32
33
34
35
36
|
#!/usr/bin/env bash
set -uo pipefail
# @describe Remove the file or directory at the specified path.
# @option --path! The path of the file or directory to remove
# @env LLM_OUTPUT=/dev/stdout The output path
ROOT_DIR="${LLM_ROOT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
OUT="${LLM_OUTPUT:-/dev/stdout}"
err() {
echo "ERROR: $*" >> "$OUT"
exit 0
}
main() {
path="${argc_path:-}"
[[ -z "$path" ]] && err "missing --path"
[[ ! -e "$path" ]] && err "path not found: $path"
if ! "$ROOT_DIR/utils/guard_path.sh" "$path" "Remove '$path'?" >>"$OUT" 2>&1; then
err "operation cancelled by user"
fi
if ! rm -rf "$path" 2>/tmp/fs_rm.err; then
msg="$(cat /tmp/fs_rm.err 2>/dev/null || true)"
err "rm failed for $path: ${msg:-unknown error}"
fi
echo "Path removed: $path" >> "$OUT"
exit 0
}
eval "$(argc --argc-eval "$0" "$@")"
main
|