From 2e965239ee4f19f86e377ade94574c3c73a32425 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 15 Jun 2000 18:04:40 +0000 Subject: ln: fixed command line parser. Added support for "--" --- coreutils/ln.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'coreutils') diff --git a/coreutils/ln.c b/coreutils/ln.c index d4fa47306..634c9905d 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -51,16 +51,14 @@ extern int ln_main(int argc, char **argv) { char *linkName; int linkIntoDirFlag; + int stopIt = FALSE; - if (argc < 3) { - usage(ln_usage); - } argc--; argv++; /* Parse any options */ - while (--argc >= 0 && *argv && **argv) { - while (**argv == '-') { + while (argc > 0 && stopIt == FALSE) { + if (**argv == '-') { while (*++(*argv)) switch (**argv) { case 's': @@ -72,15 +70,21 @@ extern int ln_main(int argc, char **argv) case 'n': followLinks = FALSE; break; + case '-': + stopIt = TRUE; + break; default: usage(ln_usage); } + argc--; + argv++; } - argv++; + else + break; } - if (argc < 1) { - fatalError("ln: missing file argument\n"); + if (argc < 2) { + usage(ln_usage); } linkName = argv[argc - 1]; -- cgit v1.2.3