From 31133309c2310c54114731b8c4068a68a4ac4279 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 17 Oct 2023 20:38:55 +0300 Subject: [PATCH] Ln --- TODO | 3 --- coreutils/ln.c | 24 +++++------------------- 2 files changed, 5 insertions(+), 22 deletions(-) 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;