bash-5.0 distribution sources and documentation

This commit is contained in:
Chet Ramey
2019-01-07 09:27:52 -05:00
parent 6444760999
commit d233b485e8
528 changed files with 84836 additions and 67099 deletions
+16 -6
View File
@@ -52,12 +52,12 @@ int
mkdir_builtin (list)
WORD_LIST *list;
{
int opt, pflag, omode, rval, nmode, parent_mode;
int opt, pflag, mflag, omode, rval, nmode, parent_mode;
char *mode;
WORD_LIST *l;
reset_internal_getopt ();
pflag = 0;
pflag = mflag = 0;
mode = (char *)NULL;
while ((opt = internal_getopt(list, "m:p")) != -1)
switch (opt)
@@ -66,8 +66,10 @@ mkdir_builtin (list)
pflag = 1;
break;
case 'm':
mflag = 1;
mode = list_optarg;
break;
CASE_HELPOPT;
default:
builtin_usage();
return (EX_USAGE);
@@ -114,7 +116,7 @@ mkdir_builtin (list)
for (rval = EXECUTION_SUCCESS, l = list; l; l = l->next)
{
if (pflag && make_path (l->word->word, nmode, parent_mode))
if (pflag && make_path (l->word->word, mflag, nmode, parent_mode))
{
rval = EXECUTION_FAILURE;
continue;
@@ -132,8 +134,9 @@ mkdir_builtin (list)
this changes the process's umask; make sure that all paths leading to a
return reset it to ORIGINAL_UMASK */
static int
make_path (path, nmode, parent_mode)
make_path (path, user_mode, nmode, parent_mode)
char *path;
int user_mode;
int nmode, parent_mode;
{
int oumask;
@@ -148,7 +151,7 @@ make_path (path, nmode, parent_mode)
return 1;
}
if (chmod (path, nmode))
if (user_mode && chmod (path, nmode))
{
builtin_error ("%s: %s", path, strerror (errno));
return 1;
@@ -172,13 +175,20 @@ make_path (path, nmode, parent_mode)
*p = '\0';
if (stat (npath, &sb) != 0)
{
if (mkdir (npath, parent_mode))
if (mkdir (npath, 0))
{
builtin_error ("cannot create directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
if (chmod (npath, parent_mode) != 0)
{
builtin_error ("cannot chmod directory `%s': %s", npath, strerror (errno));
umask (original_umask);
free (npath);
return 1;
}
}
else if (S_ISDIR (sb.st_mode) == 0)
{