diff --git a/TODO b/TODO index 206db62..1e896a6 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -*1/2: -ln - *Todo: chmod chown diff --git a/coreutils/ln.c b/coreutils/ln.c index 0534e4a..b7131b9 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -24,32 +24,18 @@ int main(const int argc, const char **argv) { else if (!strcmp("-s", argv[i])) s_flag = 1; - else { + else if (!strcmp("-h", argv[i])) { printf("ln [-s] [TARGET] [LINK/DIR]\n"); return 0; } } - switch (argc - i) { - case 0: - fprintf(stderr, "ln: missing operand\n"); + if (argc - i == 2) { + if (single_link(argv[i], argv[i + 1])) { + fprintf(stderr, "ln: %s %s\n", argv[i], strerror(errno)); return 1; - - case 1: - fprintf(stderr, "ln: missing destination\n"); - return 1; - - case 2: - if (single_link(argv[i], argv[i + 1])) { - fprintf(stderr, "ln: %s %s\n", argv[i], strerror(errno)); - return 1; - } - - break; - - default: - break; + } } return 0;