mirror of
git://git.suckless.org/sbase
synced 2024-12-22 23:13:44 +00:00
ln: try link first
This commit is contained in:
parent
2835d9ecda
commit
807d45aa80
11
ln.c
11
ln.c
@ -34,7 +34,14 @@ main(int argc, char *argv[])
|
||||
int
|
||||
ln(const char *s1, const char *s2)
|
||||
{
|
||||
if(fflag && remove(s2) == -1 && errno != ENOENT)
|
||||
int (*flink)(const char *, const char *) = sflag ? symlink : link;
|
||||
|
||||
if(flink(s1, s2) == 0)
|
||||
return 0;
|
||||
if(fflag && errno == EEXIST) {
|
||||
if(remove(s2) == -1)
|
||||
eprintf("remove %s:", s2);
|
||||
return (sflag ? symlink : link)(s1, s2);
|
||||
return flink(s1, s2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ fnck(const char *a, const char *b, int (*fn)(const char *, const char *))
|
||||
|
||||
if(stat(a, &sta) == 0 && stat(b, &stb) == 0
|
||||
&& sta.st_dev == stb.st_dev && sta.st_ino == stb.st_ino)
|
||||
eprintf("%s: same file as: %s\n", b, a);
|
||||
eprintf("%s -> %s: same file\n", a, b);
|
||||
if(fn(a, b) == -1)
|
||||
eprintf("%s:", b);
|
||||
eprintf("%s -> %s:", a, b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user