X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fumask.def;h=f73411303c8b31fcbbbfbae2fbb2eafd5d587933;hb=cce855bc5b117cb7ae70064131120687bc69fac0;hp=85bf220b924567a251735e52f07fd6f2e0dd4106;hpb=e8ce775db824de329b81293b4e5d8fbd65624528;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/umask.def b/builtins/umask.def index 85bf220..f734113 100644 --- a/builtins/umask.def +++ b/builtins/umask.def @@ -23,19 +23,23 @@ $PRODUCES umask.c $BUILTIN umask $FUNCTION umask_builtin -$SHORT_DOC umask [-S] [mode] +$SHORT_DOC umask [-p] [-S] [mode] The user file-creation mask is set to MODE. If MODE is omitted, or if `-S' is supplied, the current value of the mask is printed. The `-S' option makes the output symbolic; otherwise an octal number is output. -If MODE begins with a digit, it is interpreted as an octal number, -otherwise it is a symbolic mode string like that accepted by chmod(1). +If `-p' is supplied, and MODE is omitted, the output is in a form +that may be used as input. If MODE begins with a digit, it is +interpreted as an octal number, otherwise it is a symbolic mode string +like that accepted by chmod(1). $END #include #include "../bashtypes.h" #include "../filecntl.h" -#include +#ifndef _MINIX +# include +#endif #if defined (HAVE_UNISTD_H) #include @@ -63,18 +67,21 @@ int umask_builtin (list) WORD_LIST *list; { - int print_symbolically, opt, umask_value; + int print_symbolically, opt, umask_value, pflag; mode_t umask_arg; - print_symbolically = 0; + print_symbolically = pflag = 0; reset_internal_getopt (); - while ((opt = internal_getopt (list, "S")) != -1) + while ((opt = internal_getopt (list, "Sp")) != -1) { switch (opt) { case 'S': print_symbolically++; break; + case 'p': + pflag++; + break; default: builtin_usage (); return (EX_USAGE); @@ -116,6 +123,8 @@ umask_builtin (list) umask_arg = umask (022); umask (umask_arg); + if (pflag) + printf ("umask%s ", (print_symbolically ? " -S" : "")); if (print_symbolically) print_symbolic_umask (umask_arg); else