From 3ed563d1575b9b912d20caf43764c5caf2c4b050 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 3 Jul 2025 23:16:26 +0900 Subject: claude-code: support zsh --- home-manager/config/sh/claude-code.sh | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 home-manager/config/sh/claude-code.sh (limited to 'home-manager/config/sh/claude-code.sh') diff --git a/home-manager/config/sh/claude-code.sh b/home-manager/config/sh/claude-code.sh new file mode 100644 index 0000000..0b467bb --- /dev/null +++ b/home-manager/config/sh/claude-code.sh @@ -0,0 +1,44 @@ +# Safe wrappers for Claude Code +if [ -n "$CLAUDECODE" ]; then + # Safe wrapper for find command + find() { + has_dangerous=0 + + for arg in "$@"; do + case "$arg" in + -delete|-exec|-execdir|-fls|-fprint|-fprint0|-fprintf|-ok|-okdir) + has_dangerous=1 + break + ;; + esac + done + + if [ $has_dangerous = 1 ]; then + echo "Error: dangerous actions, -delete/-exec/-execdir/-fls/-fprint/-fprint0/-fprintf/-ok/-okdir, are not allowed in Claude Code environment" >&2 + return 1 + fi + + command find "$@" + } + + # Safe wrapper for fd command + fd() { + has_dangerous=0 + + for arg in "$@"; do + case "$arg" in + -x|--exec|-X|--exec-batch) + has_dangerous=1 + break + ;; + esac + done + + if [ $has_dangerous = 1 ]; then + echo "Error: dangerous actions, -x/--exec/-X/--exec-batch, are not allowed in Claude Code environment" >&2 + return 1 + fi + + command fd "$@" + } +fi \ No newline at end of file -- cgit v1.2.3-70-g09d2