Skip to content

Commit 6fc6b86

Browse files
committed
chore: Allow rm-tmp.sh to remove directories under .claude/tmp/
1 parent b88d705 commit 6fc6b86

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

.claude/scripts/rm-tmp.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#!/usr/bin/env bash
2-
# rm-tmp.sh — Delete files under .claude/tmp/ only.
2+
# rm-tmp.sh — Delete files or directories under .claude/tmp/ only.
33
# Usage: bash <path>/rm-tmp.sh <path> [<path> ...]
44
#
5-
# Restricts deletion to files under the project's .claude/tmp/ directory
5+
# Restricts deletion to paths under the project's .claude/tmp/ directory
66
# so that Bash(rm:*) need not be added to the permission allowlist.
7-
# Rejects: paths outside .claude/tmp/, paths containing '..', and directories.
7+
# Rejects: paths outside .claude/tmp/, paths containing '..',
8+
# and the .claude/tmp/ root itself (only sub-paths may be deleted).
9+
# Directories are removed recursively.
810

911
set -euo pipefail
1012

1113
if [ $# -eq 0 ]; then
12-
echo "Error: at least one file path is required" >&2
14+
echo "Error: at least one path is required" >&2
1315
exit 2
1416
fi
1517

@@ -28,10 +30,13 @@ for target in "$@"; do
2830
exit 1
2931
fi
3032

31-
if [ -d "${normalized}" ]; then
32-
echo "Error: directory deletion is not allowed: ${target}" >&2
33+
# Reject the bare .claude/tmp/ root (must have at least one path
34+
# component beneath it). Trailing slash is normalized away first.
35+
stripped="${normalized%/}"
36+
if [[ "${stripped}" == "${ALLOWED_PREFIX%/}" ]]; then
37+
echo "Error: deleting the .claude/tmp/ root itself is not allowed: ${target}" >&2
3338
exit 1
3439
fi
3540

36-
rm -f -- "${normalized}"
41+
rm -rf -- "${normalized}"
3742
done

0 commit comments

Comments
 (0)