• 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: "~" vs. "POSIX file"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "~" vs. "POSIX file"


  • Subject: Re: "~" vs. "POSIX file"
  • From: "Mark J. Reed" <email@hidden>
  • Date: Tue, 24 Oct 2006 16:41:32 -0400

On 10/24/06, Christopher Nebel <email@hidden> wrote:
I'd point out that other scripting languages, even ones that grew up
on Unix, do not support that, and they don't support it because "~"
isn't actually part of POSIX path syntax.

Ah, but this is Philip, so he'll just point out that tclsh supports it, which of course means that everything else should, too. :)

For instance, in Perl you'd say

"$ENV{'HOME'}/Desktop/some.text"

To be fair, in Perl you can also say glob('~/Desktop/some.text'). I don't know of any scripting languages other than the shells and Tcl that *automatically* do tilde-expansion on filename strings, but almost all come with a standard mechanism for doing so on request. Python has os.path.expanduser(); Ruby offers File::expand_path() ...

The equivalent in AppleScript would be

POSIX file ((system attribute "HOME") & "/Desktop/some.txt")

Alternatively there's this woefully inefficient option which I unhesitatingly fail utterly to recommend.

           POSIX file (do shell script "echo ~/Desktop/some.txt")

--
Mark J. Reed <email@hidden>
_______________________________________________
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/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: "~" vs. "POSIX file"
      • From: Philip Aker <email@hidden>
    • Re: "~" vs. "POSIX file"
      • From: Gnarlodious <email@hidden>
    • Re: "~" vs. "POSIX file"
      • From: kai <email@hidden>
    • Re: "~" vs. "POSIX file"
      • From: "Mark J. Reed" <email@hidden>
References: 
 >How can I open attachment in Mail ? (From: Victor Frenklakh <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: kai <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: Philip Aker <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: kai <email@hidden>)
 >Re: How can I open attachment in Mail ? (From: Philip Aker <email@hidden>)
 >"~" vs. "POSIX file" (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: "~" vs. "POSIX file"
  • Next by Date: Re: Applescript to trap when I insert my ipod?
  • Previous by thread: Re: "~" vs. "POSIX file"
  • Next by thread: Re: "~" vs. "POSIX file"
  • Index(es):
    • Date
    • Thread