This file is setattr.def, from which is created setattr.c.
It implements the builtins "export" and "readonly", in Bash.
-Copyright (C) 1987-2014 Free Software Foundation, Inc.
+Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#if defined (ARRAY_VARS)
WORD_LIST *nlist, *tlist;
WORD_DESC *w;
+ char optw[8];
+ int opti;
#endif
functions_only = arrays_only = assoc_only = 0;
#endif
case 'p':
break;
+ CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
{
tlist = list->next;
list->next = (WORD_LIST *)NULL;
- w = arrays_only ? make_word ("-ra") : make_word ("-rA");
+ /* Add -g to avoid readonly/export creating local variables:
+ only local/declare/typeset create local variables */
+ opti = 0;
+ optw[opti++] = '-';
+ optw[opti++] = 'g';
+ if (attribute & att_readonly)
+ optw[opti++] = 'r';
+ if (attribute & att_exported)
+ optw[opti++] = 'x';
+ if (arrays_only)
+ optw[opti++] = 'a';
+ else
+ optw[opti++] = 'A';
+ optw[opti] = '\0';
+
+ w = make_word (optw);
nlist = make_word_list (w, list);
+
opt = declare_builtin (nlist);
if (opt != EXECUTION_SUCCESS)
assign_error++;