blob: e62ee897ec92e3491b6546137a7690ca8b39307d (
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
|
#!/usr/bin/env bash
set -uo pipefail
# @describe List all files and directories at the specified path.
# @option --path! The path of the directory to list
# @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"
[[ ! -e "$path" ]] && err "path not found: $path"
[[ ! -d "$path" ]] && err "not a directory: $path"
# -1A: ein Eintrag pro Zeile, inkl. dotfiles (ohne . und ..)
if ! ls -1A "$path" >> "$OUT" 2>/tmp/fs_ls.err; then
msg="$(cat /tmp/fs_ls.err 2>/dev/null || true)"
err "ls failed for $path: ${msg:-unknown error}"
fi
exit 0
}
eval "$(argc --argc-eval "$0" "$@")"
main
|