4 ms·
Because the expansion of the wildcard needs to happen with the privileges granted by sudo. If you just ran "sudo rm ..." the expansion would be done by the curr
by ptx 3y ago
Because the expansion of the wildcard needs to happen with the privileges granted by sudo. If you just ran "sudo rm ..." the expansion would be done by the current shell, which doesn't have the required privileges.
- mcguire 3y agoPardon, but with double quotes, is'nt the expansion going to be done by the current shell anyway?
- mh- 3y agoglobs aren't expanded in double quotes (not in bash or zsh, at least).
- NotYourLawyer 3y agoOh, makes sense. Thanks.
- Arnavion 3y agoI don't know anything about MacOS. Normal users don't have r-x on /Users ? How do they access their own /Users/whatever homedir then?
- nicolas_17 3y agoNormal users have r-x on /Users, but for that wildcard to work, they would need r-x on /Users/foo, /Users/foo/Library, and /Users/foo/Library/LaunchAgents, for every "foo" user in the system.
- Arnavion 3y agoFor that exact command, yes. But if `/Users/*` by itself can be expanded without root you can construct the list of files to delete without needing the `zsh -c`. Eg `for d in /Users/*; do sudo rm -f "$d/Library/LaunchAgents/NightOwlUpdater.plist"; done` It's a minor point overall. I was just checking if MacOS had something else going on with its file permissions.