logo

cmd-glob

glob(1) wrapper around glob(3), inspired by https://github.com/isaacs/node-glob git clone https://anongit.hacktivis.me/git/cmd-glob.git/
commit: 2347e7df7ba313be16f16d11a7409fded050c27f
parent 05d56e99f0ada6175893c0a8762c545a3bd2b0f5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 22 Sep 2025 09:22:24 +0200

use for-loop for getopt()

Diffstat:

Mglob.c7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/glob.c b/glob.c @@ -9,11 +9,9 @@ int main(int argc, char *argv[]) { - int c = EOF; int flags = GLOB_NOSORT; - /* flawfinder: ignore. Old implementations of getopt should fix themselves */ - while((c = getopt(argc, argv, "m")) != EOF) + for(int c = -1; (c = getopt(argc, argv, "m")) != -1;) { switch(c) { @@ -29,7 +27,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if(argc == 0) { + if(argc == 0) + { fprintf(stderr, "Usage: glob [-m] pattern ...\n"); return 1; }