Re: HFS paths (was Tell Blocks Considered Harmful)
Re: HFS paths (was Tell Blocks Considered Harmful)
- Subject: Re: HFS paths (was Tell Blocks Considered Harmful)
- From: "Mark J. Reed" <email@hidden>
- Date: Sun, 21 Dec 2008 14:53:17 -0500
On Sun, Dec 21, 2008 at 12:30 PM, Doug McNutt <email@hidden> wrote:
> There are cases in real UNIX that require a trailing solidus to imply a
> directory
It would be more accurate to say that there are UNIX commands which
take advantage of the fact that a trailing slash in a POSIX pathname
doesn't change the identity of the referenced file. It allows the
user to convey the intent that it refer to a directory, but the actual
application behavior in the face of that information is idiosyncratic.
Most ignore it, and it's easily lost along the way if transformations
are done.
Take your example:
> scp $HOME/somefile FarAway:/home/me/
If faraway:/home/me is an existing directory, then
scp ~/somefile faraway:/home/me
and
scp ~/somefile faraway:/home/me/
both do the same thing. The presence of the slash doesn't alter the
behavior at all.
But if faraway:/home/me doesn't exist, or exists but is a file, then
scp ~/somefile faraway:/home/me
will behave the same as above, while
scp ~/somefile faraway:/home/me/
will fail with an error.
Now consider rsync, which performs the same basic function.
rsync -a ~/somefile faraway:/home/me
will create or replace faraway:/home/me as a copy of somefile, or
faraway:/home/me/somefile if /home/me exists as a directory - just
like scp. But add a slash:
rsync -a ~/somefile faraway:/home/me/
and it will create or replace faraway:/home/me/somefile, even going as
far as creating the directory /home/me if it doesn't exist. But it
will still fail if /home/me is a file.
Meanwhile,
rsync -a ~/somedir faraway:/home/me
Even without a trailing slash on /home/me, that will create
faraway:/home/me/somedir; if you instead want the contents of
$HOME/somedir copied into /home/me, then you put a trailing slash on
the *source* directory:
rsync -a ~/somedir/ faraway:/home/me
--
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/archives/applescript-users
This email sent to email@hidden