ln -f
This commit is contained in:
parent
59e09c9963
commit
e565522068
7
ln.1
7
ln.1
|
@ -3,12 +3,12 @@
|
||||||
ln \- make links between files
|
ln \- make links between files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B ln
|
.B ln
|
||||||
.RB [ \-s ]
|
.RB [ \-fs ]
|
||||||
.I file
|
.I file
|
||||||
.RI [ name ]
|
.RI [ name ]
|
||||||
.P
|
.P
|
||||||
.B ln
|
.B ln
|
||||||
.RB [ \-s ]
|
.RB [ \-fs ]
|
||||||
.RI [ file ...]
|
.RI [ file ...]
|
||||||
.RI [ directory ]
|
.RI [ directory ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -18,6 +18,9 @@ it is linked into the current directory. If multiple files are listed they will
|
||||||
be linked into the given directory.
|
be linked into the given directory.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
.B \-f
|
||||||
|
remove existing destinations.
|
||||||
|
.TP
|
||||||
.B \-s
|
.B \-s
|
||||||
create a symlink.
|
create a symlink.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
|
|
23
ln.c
23
ln.c
|
@ -1,23 +1,40 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
static int ln(const char *, const char *);
|
||||||
|
|
||||||
|
static bool sflag = false;
|
||||||
|
static bool fflag = false;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool sflag = false;
|
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while((c = getopt(argc, argv, "s")) != -1)
|
while((c = getopt(argc, argv, "fs")) != -1)
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
case 'f':
|
||||||
|
fflag = true;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
sflag = true;
|
sflag = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
enmasse(argc - optind, &argv[optind], sflag ? symlink : link);
|
enmasse(argc - optind, &argv[optind], ln);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ln(const char *s1, const char *s2)
|
||||||
|
{
|
||||||
|
if(fflag && remove(s2) != 0 && errno != ENOENT)
|
||||||
|
eprintf("remove %s:", s2);
|
||||||
|
return (sflag ? symlink : link)(s1, s2);
|
||||||
|
}
|
||||||
|
|
2
uname.c
2
uname.c
|
@ -40,7 +40,7 @@ main(int argc, char *argv[])
|
||||||
default:
|
default:
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if(uname(&u) == -1)
|
if(uname(&u) != 0)
|
||||||
eprintf("uname:");
|
eprintf("uname:");
|
||||||
|
|
||||||
if(sflag || !(nflag || rflag || vflag || mflag))
|
if(sflag || !(nflag || rflag || vflag || mflag))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user