luckman212 / screencapture-nag-remover

Small tool to disable macOS 15's annoying new screencapture nag popups
https://news.ycombinator.com/item?id=41658492
29 stars 1 forks source link

Syntax Error? #2

Closed wilburwilliamson closed 2 weeks ago

wilburwilliamson commented 2 weeks ago

First off, thanks for your work on this. I'm a new Mac user so perhaps I'm just doing something wrong but I'm getting a syntax error when I try to run this on my MBP m3 running 15.0:

owner@Mac bin % sudo sh screencapture-nag-remover.sh -a /Applications/AltTab.app/Contents/MacOS/AltTab screencapture-nag-remover.sh: line 12: syntax error near unexpected token <' screencapture-nag-remover.sh: line 12:IFS='.' read -r MAJ MIN _ < <(/usr/bin/swvers --productVersion)' owner@Mac bin % sudo sh /Users/owner/Downloads/screencapture-nag-remover.sh -a /Applications/AltTab.app/Contents/MacOS/AltTab /Users/owner/Downloads/screencapture-nag-remover.sh: line 12: syntax error near unexpected token <' /Users/owner/Downloads/screencapture-nag-remover.sh: line 12:IFS='.' read -r MAJ MIN < <(/usr/bin/sw_vers --productVersion)'

Any help you can offer is appreciated.

luckman212 commented 2 weeks ago

You do not (and should not) need to run the script as root (so don't type sudo in front of it)

By running sudo sh explicitly you have forced the shell to ignore the "shebang" present in the script which instructs it to run in a Bash shell (your default shell is probably Zsh, which has a different syntax and that's why you got the error above).

So TLDR, try simply running the script "as-is" by executing

/usr/local/bin/screencapture-nag-remover.sh

If you placed the script somewhere else, then put that in front instead of /usr/local/bin

I updated the README slightly to try to make this a little more clear. Let me know!

wilburwilliamson commented 2 weeks ago

Thanks, I was pretty certain it was user error. I was trying to run as sudo since I was getting a zsh permission denied error when I tried to run it initially, despite having given Terminal full disk access. Turns out that was due to Apple Quarantine attribute on script. After running: xattr -d com.apple.quarantine screencapture-nag-remover.sh and then marking script executable: chmod +x screencapture-nag-remover.sh I was able to run it successfully. Thanks so much.

luckman212 commented 2 weeks ago

Great, glad you figured that part out! I updated the README again to reflect that removing the quarantine flag might be required.