ln -f
This commit is contained in:
23
ln.c
23
ln.c
@@ -1,23 +1,40 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "util.h"
|
||||
|
||||
static int ln(const char *, const char *);
|
||||
|
||||
static bool sflag = false;
|
||||
static bool fflag = false;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
bool sflag = false;
|
||||
char c;
|
||||
|
||||
while((c = getopt(argc, argv, "s")) != -1)
|
||||
while((c = getopt(argc, argv, "fs")) != -1)
|
||||
switch(c) {
|
||||
case 'f':
|
||||
fflag = true;
|
||||
break;
|
||||
case 's':
|
||||
sflag = true;
|
||||
break;
|
||||
default:
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
enmasse(argc - optind, &argv[optind], sflag ? symlink : link);
|
||||
enmasse(argc - optind, &argv[optind], ln);
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user