summaryrefslogtreecommitdiff
path: root/ln.c
diff options
context:
space:
mode:
authorPavel Roskin2000-06-15 18:04:40 +0000
committerPavel Roskin2000-06-15 18:04:40 +0000
commit2e965239ee4f19f86e377ade94574c3c73a32425 (patch)
treed77dd91a7e2d4f2c8edab88b75daace67d828307 /ln.c
parent3f75503fa0b747b6d505ffe8ec047f6894f81050 (diff)
downloadbusybox-2e965239ee4f19f86e377ade94574c3c73a32425.zip
busybox-2e965239ee4f19f86e377ade94574c3c73a32425.tar.gz
ln: fixed command line parser. Added support for "--"
Diffstat (limited to 'ln.c')
-rw-r--r--ln.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/ln.c b/ln.c
index d4fa473..634c990 100644
--- a/ln.c
+++ b/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];