Re: "~" vs. "POSIX file"
Re: "~" vs. "POSIX file"
- Subject: Re: "~" vs. "POSIX file"
- From: Philip Aker <email@hidden>
- Date: Tue, 24 Oct 2006 21:28:51 -0700
On 2006-10-24, at 14:07:35, Mark J. Reed wrote:
The standard shells do expansion of leading unquoted tildes on all
words as part of standard command-line processing, before the
arguments are passed to any command, no matter what that command
may be:
$ echo ~
/Users/mreed
Tclsh, on the other hand, does not;
Here's my tcl script (zzz.tcl, exec perms):
#!/bin/sh
# By Philip Aker <email@hidden> \
exec tclsh "$0" "$@"
puts [lindex $argv 0];
Here's the calls:
# zzz.tcl ~/zzz.tcl
/Users/me/zzz.tcl
# tclsh zzz.tcl ~/zzz.tcl
/Users/me/zzz.tcl
# tclsh
% puts ~/Desktop
~/Desktop
#
# ruby
puts "~/Desktop"
~/Desktop
#
# perl
print("~/Desktop");
~/Desktop#
So really, the question is whether or not one is in a shell or an
interpreter. tclsh is badly named in this respect. It's behavior is
as perl and ruby in the above examples.
such expansion is done by the file(n) command on its own arguments.
This can lead to some apparent inconsistencies:
% file exists ~/foo.txt
1
% cat ~/foo.txt
cat: ~/foo.txt: No such file or directory
child process exited abnormally
There is no inconsistency. See above. tclsh uses tilde expansion
where appropriate (not only for 'file'). It can't possibly know what
input form an exec'd call needs and wouldn't presume to guess. In
your example above, tclsh passes (as always) a string, not a file.
# tclsh
% cd /;set f [open ~/Desktop/foo.txt w];puts $f {faux pas}; close
$f;exit;
#
Philip Aker
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