commit bash-20181226 snapshot

This commit is contained in:
Chet Ramey
2019-01-03 10:19:09 -05:00
parent 6870125961
commit 89b3a79dd4
16 changed files with 136 additions and 16 deletions
+1
View File
@@ -46,6 +46,7 @@ basename_builtin (list)
if (no_options (list))
return (EX_USAGE);
list = loptend;
string = list->word->word;
suffix = (char *)NULL;
+5 -3
View File
@@ -30,6 +30,7 @@
#include "builtins.h"
#include "shell.h"
#include "common.h"
#include "bashgetopt.h"
int
dirname_builtin (list)
@@ -38,15 +39,16 @@ dirname_builtin (list)
int slen;
char *string;
if (no_options (list))
return (EX_USAGE);
list = loptend;
if (list == 0 || list->next)
{
builtin_usage ();
return (EX_USAGE);
}
if (no_options (list))
return (EX_USAGE);
string = list->word->word;
slen = strlen (string);
+15 -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,6 +66,7 @@ mkdir_builtin (list)
pflag = 1;
break;
case 'm':
mflag = 1;
mode = list_optarg;
break;
CASE_HELPOPT;
@@ -115,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;
@@ -133,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;
@@ -149,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;
@@ -173,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)
{