This is a discussion on Re: patch for mkdir: specifying mode for intermediate dirs created by -p within the lucky.openbsd.tech forums, part of the OpenBSD category; --> This is a bad idea. It is an incompatible extension. Then people use it in scripts. Then their scripts ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| This is a bad idea. It is an incompatible extension. Then people use it in scripts. Then their scripts become non-portable. > Here is a patch for mkdir to add in a -i <mode> option to specify the > mode of intermediate directories when using -p. This would come in > very handy for me, don't know if anyone else would even want this, but > didn't take long to write. > > Index: mkdir.c > ================================================== ================= > RCS file: /home/cvs/src/bin/mkdir/mkdir.c,v > retrieving revision 1.17 > diff -u -r1.17 mkdir.c > --- mkdir.c 1 Jul 2004 18:25:47 -0000 1.17 > +++ mkdir.c 21 Apr 2005 20:43:55 -0000 > @@ -79,7 +79,7 @@ > dir_mode = mode | S_IWUSR | S_IXUSR; > > pflag = 0; > - while ((ch = getopt(argc, argv, "m > + while ((ch = getopt(argc, argv, "i:m > switch(ch) { > case 'p': > pflag = 1; > @@ -90,6 +90,12 @@ > mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO); > free(set); > break; > + case 'i': > + if ((set = setmode(optarg)) == NULL) > + errx(1, "invalid file mode: %s", optarg); > + dir_mode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO); > + free(set); > + break; > default: > usage(); > } > @@ -175,6 +181,6 @@ > void > usage(void) > { > - (void)fprintf(stderr, "usage: %s [-p] [-m mode] dirname > ...\n", __progname); > + (void)fprintf(stderr, "usage: %s [-p] [-m mode] [-i imode] > dirname ...\n", __progname); > exit(1); > } |
| Thread Tools | |
| Display Modes | |
|
|