Re: shell script to change permissions
Re: shell script to change permissions
- Subject: Re: shell script to change permissions
- From: Christopher Nebel <email@hidden>
- Date: Thu, 31 Jul 2008 13:42:06 -0700
On Jul 31, 2008, at 12:19 PM, Mark J. Reed wrote:
On Thu, Jul 31, 2008 at 2:57 PM, Christopher Nebel
<email@hidden> wrote:
cd foo && ( chown -R me . ; chmod -R a=rwx . )
If you aren't explicitly taking advantage of the "parens make a
subshell" feature, braces work for grouping, too, and are arguably a
better indicator of intent. You do need a semicolon before the
closing brace if it's on the same line, however:
cd foo && { chown -R me . ; chmod -R a=rwx . ; }
Good point. (Talk to me long enough about this sort of thing, and
you'll discover I don't know sh *that* well.)
Also, something I forgot to mention before. This:
set f1 to quoted form of POSIX path of f
set userHome to (short user name of (system info)) as string
set f2 to userHome & "/Desktop"
if f1 contains f2 then
...is not an entirely reliable way to figure out if something is on
the desktop. First, there's no particular guarantee that the desktop
folder will be named "Desktop", and second, users can change their
home directory to be anywhere -- there's no requirement that it be
named with their short user name. Now, practically speaking, the
first is unlikely to change, and most users don't bother with the
second, so you'll probably be fine. However, the proper way to do
this would be to test the file containment using something that (a)
knows where the desktop is and (b) knows about file containment.
Finder and System Events satisfy both conditions, though it's a bit
more straightforward in System Events:
set f to choose file
tell application "System Events"
set isInDesktop to container of f is desktop folder
end tell
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden