Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Overkill | 9 comments | Create New Account
Click here to return to the 'Overkill' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Authored by: bankshot on Oct 08, '10 01:36:30PM

Just as sudo is unnecessary to kill iTunes and change directory permissions, the "-9" argument to killall is really unnecessary. It doesn't give iTunes a chance to exit gracefully and do the normal cleanup that it does when it exits. Either a regular killall without "-9" would be better, or just tell the user to quit. Heck, you could even do it via AppleScript:

osascript -e 'tell application "iTunes" to quit'

The current method is kind of like using a sledgehammer to ring a doorbell - it'll get the job done, but it's overkill and may cause unintended damage.

The one way in which sudo would be useful here is if the script changed ownership of the directories to root. Then a future version of iTunes wouldn't be able to change permissions back. As it is now, if the directories don't exist, they will be owned by root (because they are created using sudo), but if they do already exist, ownership won't change. I'd just create directories as the user and then only use sudo to chown them to root.

Finally, I'd prefer to move any existing updates out of the way rather than deleting them.

[ Reply to This | # ]
Authored by: bglnelissen on Oct 09, '10 02:32:13AM
Running oascript on Snow Leopard can give a strange error. To prevent this you can change: osascript to: arch -i386 osascript

[ Reply to This | # ]