[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does make strip / at the end of a directory prerequisite??

From: Stephan Beal
Subject: Re: why does make strip / at the end of a directory prerequisite??
Date: Thu, 8 Sep 2011 15:21:25 +0200

On Thu, Sep 8, 2011 at 3:12 PM, Mark Galeck (CW) <address@hidden>wrote:

> address@hidden: ls dir/
> foobar

Just FYI:

if foobar is a symlink to a dir then 'ls foobar' and 'ls foobar/' will give
you different results.

That is only to point out that the two are not 100% semantically equivalent
in all contexts:

address@hidden:~/tmp]$ ln -s /etc foo
address@hidden:~/tmp]$ l foo
lrwxrwxrwx 1 stephan stephan 4 Sep  8 15:16 foo -> /etc
address@hidden:~/tmp]$ l foo/
total 1344
drwxr-xr-x 157 root    root     12288 Sep  8 10:12 .

Another example of when they're not 100% equivalent is when copying/moving
multiple files and the final target is a directory which does not exist:

address@hidden:~/tmp]$ touch a b c
address@hidden:~/tmp]$ cp a b c d
cp: target `d' is not a directory

address@hidden:~/tmp]$ cp a b c d/
cp: accessing `d/': Not a directory

When copying _single_ files this way, the former can be semantically broken
if the target dir does not exist (because a _file_ will be created with the
target name), a problem one can work around by always adding the trailing
slash to the target:

address@hidden:~/tmp]$ cp a y
address@hidden:~/tmp]$ cp a z/
cp: cannot create regular file `z/': Is a directory

by adding the slash, you cause the copy/mv to fail if the dir doesn't exist
(i often find this useful, and have gotten in the habit of always adding /.
to the end of cp/mv/scp paths).

----- stephan beal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]