-
Notifications
You must be signed in to change notification settings - Fork 5
Fix AppleScript syntax error in smart-notify.sh #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix AppleScript syntax error in smart-notify.sh #4
Conversation
Fixes AppleScript syntax error when notification messages or titles contain special characters like double quotes or backslashes. The osascript fallback path (when terminal-notifier is unavailable) was not properly escaping variables before passing them to AppleScript, causing syntax errors like "identifier can't go after this". Solution: Use sed to escape backslashes and double quotes in $MSG and $TITLE variables before interpolating them into the AppleScript command. Single quotes do not need escaping in AppleScript double-quoted strings. Tested with: - Double quotes - Single quotes/apostrophes - Parentheses - Backslashes - Mixed special characters Closes verygoodplugins#3
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)templates/claude-code/scripts/*.sh📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Fixes #3
Resolves AppleScript syntax error in
smart-notify.shwhen notification messages contain special characters.Problem
The Stop hook was failing with syntax errors when messages contained special characters:
Solution
Added proper escaping for
$MSGand$TITLEvariables before passing toosascript:\→\\"→\"Changes
templates/claude-code/scripts/smart-notify.shline 54-60sedfor backslashes and double quotesTesting
Comprehensive testing with various special characters:
Message with "double quotes"Message with 'single quotes'Complex: "test" (with) 'apostrophe'Message with (parentheses)Backslash \ testMixed: "quoted" and 'apostrophe' with \ backslashAll 8 test cases passed successfully with notifications displaying correctly on macOS.
Impact
terminal-notifierinstalledScreenshots
Notifications now display correctly with special characters instead of throwing AppleScript syntax errors.