• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: shell script to change permissions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script to change permissions


  • Subject: Re: shell script to change permissions
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 31 Jul 2008 15:20:54 -0400

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 . ; }

You might prefer to continue chaining with && ; in this case, that
would mean that the chmod won't run unless the chown succeeds:

cd foo && chown -R me . && chmod -R a=rwx .

Note that you don't need any grouping in that case.

All of these sequences of commands will leave foo as the current
working directory at the end.  If they are the entirety of the script,
no big deal, but if there's more shell to come, you can revert to the
previous working directory by putting the whole thing in (another set
of) parens.

(cd foo ...)  pwd  # no longer in foo here
 _______________________________________________
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

References: 
 >shell script to change permissions (From: Jim Weisbin <email@hidden>)
 >Re: shell script to change permissions (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Reading XMP metadata from a JPEG
  • Next by Date: AppleScript bug/change/feature in iTunes 7.7.1?
  • Previous by thread: Re: shell script to change permissions
  • Next by thread: Re: shell script to change permissions
  • Index(es):
    • Date
    • Thread