• 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: POSIX file wierdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX file wierdness


  • Subject: Re: POSIX file wierdness
  • From: has <email@hidden>
  • Date: Mon, 9 May 2005 15:49:09 +0100

Alastair Rankine wrote:

>>>POSIX file "foo"
>
>OK so you're basically saying that "foo" isn't a "slash-delimited path" as required by the POSIX file extension, and so all bets are off?

Unlike a Unix script, an AppleScript script has no inherent notion of its position in the filesystem, so relative paths are meaningless to it. Always use absolute paths. This is a separate issue to your magical munging keyword problem, however.


>POSIX file "/Users/alastair"
>
>changes to the following when compiled:
>
>file "al2book:Users:alastair"

The logic of transforming the 'POSIX file' keyword into 'file' when pretty-printing AS source code escapes me as well. If you write:

    file specification "al2book:Users:alastair"

you'll notice it does the same for that as well:

    file "al2book:Users:alastair"

IIRC, such transformations didn't cause any practical problems in older versions of AS as the AS compiler was also able to parse the abbreviated expression into something meaningful (a file specification, I think). However, something seems to have changed in recent AS releases that means this is no longer true. Fortunately, the workaround is simple enough: instead of declaring a POSIX file object in your source code, declare a string and coerce it to a POSIX file object at runtime; i.e. replace:

    POSIX file "/Users/alastair"

with:

    "/Users/alastair" as POSIX file

The semantics aren't quite the same, but it shouldn't cause you any problems in practice.

You might also consider filing a Radar bug requesting that AppleScript's pretty printer stop rewriting 'POSIX file "/some/posix/path"' as 'file "some:hfs:path"', because it's a bit of a liberty to take with folks' source code in the first place and now introduces bugs into it as well. I'm also told that translating POSIX path strings to HFS path strings is inherently unsafe as the former are guaranteed to be unique but the latter are not, which is yet another reason for not doing it.

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Nice Automator article on O'Reilly
  • Next by Date: Re: Nice Automator article on O'Reilly
  • Previous by thread: Re: POSIX file wierdness
  • Next by thread: email-addresses are 1big email-address
  • Index(es):
    • Date
    • Thread