Re: "~" vs. "POSIX file"
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