logo

utils-std

Collection of commonly available Unix tools
commit: 4468dddb752819e9498dfd99c6b23193d0674c3d
parent 3f00af9a25a017b1d7fa7614cb964c151b969afc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 13 May 2024 01:54:22 +0200

cmd/install: Require source & destination without -d

Diffstat:

Mcmd/install.14++--
Mcmd/install.c20++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cmd/install.1 b/cmd/install.1 @@ -13,8 +13,8 @@ .Op Fl g Ar group .Op Fl m Ar mode .Op Fl o Ar owner -.Op Ar source... -.Op Ar destination +.Ar source... +.Ar destination .Nm .Fl d .Op Fl c diff --git a/cmd/install.c b/cmd/install.c @@ -268,19 +268,19 @@ main(int argc, char *argv[]) return 0; } - if(argc == 2) + if(argc < 2) { - if(do_install(argv[0], argv[1], false) < 0) return 1; + fprintf(stderr, "%s: Expected at least 2 arguments, got %d\n", argv0, argc); + return 1; } - else - { - char *dest = argv[argc - 1]; - for(int i = 0; i < argc - 1; i++) - { - char *src = argv[i]; - if(do_install(src, dest, true) < 0) return 1; - } + char *dest = argv[argc - 1]; + bool multi_src = argc > 2; + + for(int i = 0; i < argc - 1; i++) + { + char *src = argv[i]; + if(do_install(src, dest, multi_src) < 0) return 1; } return 0;