| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/setattr.def |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | This file is setattr.def, from which is created setattr.c. | - | ||||||||||||||||||||||||
| 2 | It implements the builtins "export" and "readonly", in Bash. | - | ||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | Copyright (C) 1987-2015 Free Software Foundation, Inc. | - | ||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | This file is part of GNU Bash, the Bourne Again SHell. | - | ||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | Bash is free software: you can redistribute it and/or modify | - | ||||||||||||||||||||||||
| 9 | it under the terms of the GNU General Public License as published by | - | ||||||||||||||||||||||||
| 10 | the Free Software Foundation, either version 3 of the License, or | - | ||||||||||||||||||||||||
| 11 | (at your option) any later version. | - | ||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | Bash is distributed in the hope that it will be useful, | - | ||||||||||||||||||||||||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | ||||||||||||||||||||||||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | ||||||||||||||||||||||||
| 16 | GNU General Public License for more details. | - | ||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | You should have received a copy of the GNU General Public License | - | ||||||||||||||||||||||||
| 19 | along with Bash. If not, see <http://www.gnu.org/licenses/>. | - | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | $PRODUCES setattr.c | - | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | #include <config.h> | - | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | #if defined (HAVE_UNISTD_H) | - | ||||||||||||||||||||||||
| 26 | # ifdef _MINIX | - | ||||||||||||||||||||||||
| 27 | # include <sys/types.h> | - | ||||||||||||||||||||||||
| 28 | # endif | - | ||||||||||||||||||||||||
| 29 | # include <unistd.h> | - | ||||||||||||||||||||||||
| 30 | #endif | - | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | #include <stdio.h> | - | ||||||||||||||||||||||||
| 33 | #include "../bashansi.h" | - | ||||||||||||||||||||||||
| 34 | #include "../bashintl.h" | - | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | #include "../shell.h" | - | ||||||||||||||||||||||||
| 37 | #include "../execute_cmd.h" | - | ||||||||||||||||||||||||
| 38 | #include "../flags.h" | - | ||||||||||||||||||||||||
| 39 | #include "common.h" | - | ||||||||||||||||||||||||
| 40 | #include "bashgetopt.h" | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | extern sh_builtin_func_t *this_shell_builtin; | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | #ifdef ARRAY_VARS | - | ||||||||||||||||||||||||
| 45 | extern int declare_builtin __P((WORD_LIST *)); | - | ||||||||||||||||||||||||
| 46 | #endif | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | #define READONLY_OR_EXPORT \ | - | ||||||||||||||||||||||||
| 49 | (this_shell_builtin == readonly_builtin || this_shell_builtin == export_builtin) | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | $BUILTIN export | - | ||||||||||||||||||||||||
| 52 | $FUNCTION export_builtin | - | ||||||||||||||||||||||||
| 53 | $SHORT_DOC export [-fn] [name[=value] ...] or export -p | - | ||||||||||||||||||||||||
| 54 | Set export attribute for shell variables. | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | Marks each NAME for automatic export to the environment of subsequently | - | ||||||||||||||||||||||||
| 57 | executed commands. If VALUE is supplied, assign VALUE before exporting. | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | Options: | - | ||||||||||||||||||||||||
| 60 | -f refer to shell functions | - | ||||||||||||||||||||||||
| 61 | -n remove the export property from each NAME | - | ||||||||||||||||||||||||
| 62 | -p display a list of all exported variables and functions | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | An argument of `--' disables further option processing. | - | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | Exit Status: | - | ||||||||||||||||||||||||
| 67 | Returns success unless an invalid option is given or NAME is invalid. | - | ||||||||||||||||||||||||
| 68 | $END | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | /* For each variable name in LIST, make that variable appear in the | - | ||||||||||||||||||||||||
| 71 | environment passed to simple commands. If there is no LIST, then | - | ||||||||||||||||||||||||
| 72 | print all such variables. An argument of `-n' says to remove the | - | ||||||||||||||||||||||||
| 73 | exported attribute from variables named in LIST. An argument of | - | ||||||||||||||||||||||||
| 74 | -f indicates that the names present in LIST refer to functions. */ | - | ||||||||||||||||||||||||
| 75 | int | - | ||||||||||||||||||||||||
| 76 | export_builtin (list) | - | ||||||||||||||||||||||||
| 77 | register WORD_LIST *list; | - | ||||||||||||||||||||||||
| 78 | { | - | ||||||||||||||||||||||||
| 79 | return (set_or_show_attributes (list, att_exported, 0)); executed 2537 times by 1 test: return (set_or_show_attributes (list, 0x0000001, 0));Executed by:
| 2537 | ||||||||||||||||||||||||
| 80 | } | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | $BUILTIN readonly | - | ||||||||||||||||||||||||
| 83 | $FUNCTION readonly_builtin | - | ||||||||||||||||||||||||
| 84 | $SHORT_DOC readonly [-aAf] [name[=value] ...] or readonly -p | - | ||||||||||||||||||||||||
| 85 | Mark shell variables as unchangeable. | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | Mark each NAME as read-only; the values of these NAMEs may not be | - | ||||||||||||||||||||||||
| 88 | changed by subsequent assignment. If VALUE is supplied, assign VALUE | - | ||||||||||||||||||||||||
| 89 | before marking as read-only. | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | Options: | - | ||||||||||||||||||||||||
| 92 | -a refer to indexed array variables | - | ||||||||||||||||||||||||
| 93 | -A refer to associative array variables | - | ||||||||||||||||||||||||
| 94 | -f refer to shell functions | - | ||||||||||||||||||||||||
| 95 | -p display a list of all readonly variables or functions, | - | ||||||||||||||||||||||||
| 96 | depending on whether or not the -f option is given | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | An argument of `--' disables further option processing. | - | ||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | Exit Status: | - | ||||||||||||||||||||||||
| 101 | Returns success unless an invalid option is given or NAME is invalid. | - | ||||||||||||||||||||||||
| 102 | $END | - | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | /* For each variable name in LIST, make that variable readonly. Given an | - | ||||||||||||||||||||||||
| 105 | empty LIST, print out all existing readonly variables. */ | - | ||||||||||||||||||||||||
| 106 | int | - | ||||||||||||||||||||||||
| 107 | readonly_builtin (list) | - | ||||||||||||||||||||||||
| 108 | register WORD_LIST *list; | - | ||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||
| 110 | return (set_or_show_attributes (list, att_readonly, 0)); executed 108 times by 1 test: return (set_or_show_attributes (list, 0x0000002, 0));Executed by:
| 108 | ||||||||||||||||||||||||
| 111 | } | - | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 114 | # define ATTROPTS "aAfnp" | - | ||||||||||||||||||||||||
| 115 | #else | - | ||||||||||||||||||||||||
| 116 | # define ATTROPTS "fnp" | - | ||||||||||||||||||||||||
| 117 | #endif | - | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | /* For each variable name in LIST, make that variable have the specified | - | ||||||||||||||||||||||||
| 120 | ATTRIBUTE. An arg of `-n' says to remove the attribute from the the | - | ||||||||||||||||||||||||
| 121 | remaining names in LIST (doesn't work for readonly). */ | - | ||||||||||||||||||||||||
| 122 | int | - | ||||||||||||||||||||||||
| 123 | set_or_show_attributes (list, attribute, nodefs) | - | ||||||||||||||||||||||||
| 124 | register WORD_LIST *list; | - | ||||||||||||||||||||||||
| 125 | int attribute, nodefs; | - | ||||||||||||||||||||||||
| 126 | { | - | ||||||||||||||||||||||||
| 127 | register SHELL_VAR *var; | - | ||||||||||||||||||||||||
| 128 | int assign, undo, any_failed, assign_error, opt; | - | ||||||||||||||||||||||||
| 129 | int functions_only, arrays_only, assoc_only; | - | ||||||||||||||||||||||||
| 130 | int aflags; | - | ||||||||||||||||||||||||
| 131 | char *name; | - | ||||||||||||||||||||||||
| 132 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 133 | WORD_LIST *nlist, *tlist; | - | ||||||||||||||||||||||||
| 134 | WORD_DESC *w; | - | ||||||||||||||||||||||||
| 135 | char optw[8]; | - | ||||||||||||||||||||||||
| 136 | int opti; | - | ||||||||||||||||||||||||
| 137 | #endif | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | functions_only = arrays_only = assoc_only = 0; | - | ||||||||||||||||||||||||
| 140 | undo = any_failed = assign_error = 0; | - | ||||||||||||||||||||||||
| 141 | /* Read arguments from the front of the list. */ | - | ||||||||||||||||||||||||
| 142 | reset_internal_getopt (); | - | ||||||||||||||||||||||||
| 143 | while ((opt = internal_getopt (list, ATTROPTS)) != -1)
| 42-2673 | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | switch (opt) | - | ||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||
| 147 | case 'n': executed 5 times by 1 test: case 'n':Executed by:
| 5 | ||||||||||||||||||||||||
| 148 | undo = 1; | - | ||||||||||||||||||||||||
| 149 | break; executed 5 times by 1 test: break;Executed by:
| 5 | ||||||||||||||||||||||||
| 150 | case 'f': executed 24 times by 1 test: case 'f':Executed by:
| 24 | ||||||||||||||||||||||||
| 151 | functions_only = 1; | - | ||||||||||||||||||||||||
| 152 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 153 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 154 | case 'a': executed 10 times by 1 test: case 'a':Executed by:
| 10 | ||||||||||||||||||||||||
| 155 | arrays_only = 1; | - | ||||||||||||||||||||||||
| 156 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||
| 157 | case 'A': executed 1 time by 1 test: case 'A':Executed by:
| 1 | ||||||||||||||||||||||||
| 158 | assoc_only = 1; | - | ||||||||||||||||||||||||
| 159 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 160 | #endif | - | ||||||||||||||||||||||||
| 161 | case 'p': executed 1 time by 1 test: case 'p':Executed by:
| 1 | ||||||||||||||||||||||||
| 162 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||
| 163 | CASE_HELPOPT; never executed: return (258);never executed: case -99: | 0 | ||||||||||||||||||||||||
| 164 | default: executed 1 time by 1 test: default:Executed by:
| 1 | ||||||||||||||||||||||||
| 165 | builtin_usage (); | - | ||||||||||||||||||||||||
| 166 | return (EX_USAGE); executed 1 time by 1 test: return (258);Executed by:
| 1 | ||||||||||||||||||||||||
| 167 | } | - | ||||||||||||||||||||||||
| 168 | } | - | ||||||||||||||||||||||||
| 169 | list = loptend; | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | if (list)
| 32-2641 | ||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||
| 173 | if (attribute & att_exported)
| 104-2537 | ||||||||||||||||||||||||
| 174 | array_needs_making = 1; executed 2537 times by 1 test: array_needs_making = 1;Executed by:
| 2537 | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | /* Cannot undo readonly status, silently disallowed. */ | - | ||||||||||||||||||||||||
| 177 | if (undo && (attribute & att_readonly))
| 0-2636 | ||||||||||||||||||||||||
| 178 | attribute &= ~att_readonly; executed 5 times by 1 test: attribute &= ~0x0000002;Executed by:
| 5 | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | while (list)
| 2641-2646 | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | name = list->word->word; | - | ||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | if (functions_only) /* xxx -f name */
| 24-2622 | ||||||||||||||||||||||||
| 185 | { | - | ||||||||||||||||||||||||
| 186 | var = find_function (name); | - | ||||||||||||||||||||||||
| 187 | if (var == 0)
| 5-19 | ||||||||||||||||||||||||
| 188 | { | - | ||||||||||||||||||||||||
| 189 | builtin_error (_("%s: not a function"), name); | - | ||||||||||||||||||||||||
| 190 | any_failed++; | - | ||||||||||||||||||||||||
| 191 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 192 | else if ((attribute & att_exported) && undo == 0 && exportable_function_name (name) == 0)
| 0-14 | ||||||||||||||||||||||||
| 193 | { | - | ||||||||||||||||||||||||
| 194 | builtin_error (_("%s: cannot export"), name); | - | ||||||||||||||||||||||||
| 195 | any_failed++; | - | ||||||||||||||||||||||||
| 196 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 197 | else | - | ||||||||||||||||||||||||
| 198 | SETVARATTR (var, attribute, undo); executed 17 times by 1 test: ((undo == 0) ? ((var)->attributes |= (attribute)) : ((var)->attributes &= ~(attribute)));Executed by:
| 17 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | list = list->next; | - | ||||||||||||||||||||||||
| 201 | continue; executed 24 times by 1 test: continue;Executed by:
| 24 | ||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | /* xxx [-np] name[=value] */ | - | ||||||||||||||||||||||||
| 205 | assign = assignment (name, 0); | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | aflags = 0; | - | ||||||||||||||||||||||||
| 208 | if (assign)
| 208-2414 | ||||||||||||||||||||||||
| 209 | { | - | ||||||||||||||||||||||||
| 210 | name[assign] = '\0'; | - | ||||||||||||||||||||||||
| 211 | if (name[assign - 1] == '+')
| 2-206 | ||||||||||||||||||||||||
| 212 | { | - | ||||||||||||||||||||||||
| 213 | aflags |= ASS_APPEND; | - | ||||||||||||||||||||||||
| 214 | name[assign - 1] = '\0'; | - | ||||||||||||||||||||||||
| 215 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 216 | } executed 208 times by 1 test: end of blockExecuted by:
| 208 | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | if (legal_identifier (name) == 0)
| 24-2598 | ||||||||||||||||||||||||
| 219 | { | - | ||||||||||||||||||||||||
| 220 | sh_invalidid (name); | - | ||||||||||||||||||||||||
| 221 | if (assign)
| 0-24 | ||||||||||||||||||||||||
| 222 | assign_error++; never executed: assign_error++; | 0 | ||||||||||||||||||||||||
| 223 | else | - | ||||||||||||||||||||||||
| 224 | any_failed++; executed 24 times by 1 test: any_failed++;Executed by:
| 24 | ||||||||||||||||||||||||
| 225 | list = list->next; | - | ||||||||||||||||||||||||
| 226 | continue; executed 24 times by 1 test: continue;Executed by:
| 24 | ||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | if (assign) /* xxx [-np] name=value */
| 208-2390 | ||||||||||||||||||||||||
| 230 | { | - | ||||||||||||||||||||||||
| 231 | name[assign] = '='; | - | ||||||||||||||||||||||||
| 232 | if (aflags & ASS_APPEND)
| 2-206 | ||||||||||||||||||||||||
| 233 | name[assign - 1] = '+'; executed 2 times by 1 test: name[assign - 1] = '+';Executed by:
| 2 | ||||||||||||||||||||||||
| 234 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 235 | /* Let's try something here. Turn readonly -a xxx=yyy into | - | ||||||||||||||||||||||||
| 236 | declare -ra xxx=yyy and see what that gets us. */ | - | ||||||||||||||||||||||||
| 237 | if (arrays_only || assoc_only)
| 0-204 | ||||||||||||||||||||||||
| 238 | { | - | ||||||||||||||||||||||||
| 239 | tlist = list->next; | - | ||||||||||||||||||||||||
| 240 | list->next = (WORD_LIST *)NULL; | - | ||||||||||||||||||||||||
| 241 | /* Add -g to avoid readonly/export creating local variables: | - | ||||||||||||||||||||||||
| 242 | only local/declare/typeset create local variables */ | - | ||||||||||||||||||||||||
| 243 | opti = 0; | - | ||||||||||||||||||||||||
| 244 | optw[opti++] = '-'; | - | ||||||||||||||||||||||||
| 245 | optw[opti++] = 'g'; | - | ||||||||||||||||||||||||
| 246 | if (attribute & att_readonly)
| 1-3 | ||||||||||||||||||||||||
| 247 | optw[opti++] = 'r'; executed 3 times by 1 test: optw[opti++] = 'r';Executed by:
| 3 | ||||||||||||||||||||||||
| 248 | if (attribute & att_exported)
| 1-3 | ||||||||||||||||||||||||
| 249 | optw[opti++] = 'x'; executed 1 time by 1 test: optw[opti++] = 'x';Executed by:
| 1 | ||||||||||||||||||||||||
| 250 | if (arrays_only)
| 0-4 | ||||||||||||||||||||||||
| 251 | optw[opti++] = 'a'; executed 4 times by 1 test: optw[opti++] = 'a';Executed by:
| 4 | ||||||||||||||||||||||||
| 252 | else | - | ||||||||||||||||||||||||
| 253 | optw[opti++] = 'A'; never executed: optw[opti++] = 'A'; | 0 | ||||||||||||||||||||||||
| 254 | optw[opti] = '\0'; | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | w = make_word (optw); | - | ||||||||||||||||||||||||
| 257 | nlist = make_word_list (w, list); | - | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | opt = declare_builtin (nlist); | - | ||||||||||||||||||||||||
| 260 | if (opt != EXECUTION_SUCCESS)
| 2 | ||||||||||||||||||||||||
| 261 | assign_error++; executed 2 times by 1 test: assign_error++;Executed by:
| 2 | ||||||||||||||||||||||||
| 262 | list->next = tlist; | - | ||||||||||||||||||||||||
| 263 | dispose_word (w); | - | ||||||||||||||||||||||||
| 264 | free (nlist); | - | ||||||||||||||||||||||||
| 265 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 266 | else | - | ||||||||||||||||||||||||
| 267 | #endif | - | ||||||||||||||||||||||||
| 268 | /* This word has already been expanded once with command | - | ||||||||||||||||||||||||
| 269 | and parameter expansion. Call do_assignment_no_expand (), | - | ||||||||||||||||||||||||
| 270 | which does not do command or parameter substitution. If | - | ||||||||||||||||||||||||
| 271 | the assignment is not performed correctly, flag an error. */ | - | ||||||||||||||||||||||||
| 272 | if (do_assignment_no_expand (name) == 0)
| 4-200 | ||||||||||||||||||||||||
| 273 | assign_error++; executed 4 times by 1 test: assign_error++;Executed by:
| 4 | ||||||||||||||||||||||||
| 274 | name[assign] = '\0'; | - | ||||||||||||||||||||||||
| 275 | if (aflags & ASS_APPEND)
| 2-206 | ||||||||||||||||||||||||
| 276 | name[assign - 1] = '\0'; executed 2 times by 1 test: name[assign - 1] = '\0';Executed by:
| 2 | ||||||||||||||||||||||||
| 277 | } executed 208 times by 1 test: end of blockExecuted by:
| 208 | ||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||
| 279 | set_var_attribute (name, attribute, undo); | - | ||||||||||||||||||||||||
| 280 | list = list->next; | - | ||||||||||||||||||||||||
| 281 | } executed 2598 times by 1 test: end of blockExecuted by:
| 2598 | ||||||||||||||||||||||||
| 282 | } executed 2641 times by 1 test: end of blockExecuted by:
| 2641 | ||||||||||||||||||||||||
| 283 | else | - | ||||||||||||||||||||||||
| 284 | { | - | ||||||||||||||||||||||||
| 285 | SHELL_VAR **variable_list; | - | ||||||||||||||||||||||||
| 286 | register int i; | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | if ((attribute & att_function) || functions_only)
| 0-17 | ||||||||||||||||||||||||
| 289 | { | - | ||||||||||||||||||||||||
| 290 | variable_list = all_shell_functions (); | - | ||||||||||||||||||||||||
| 291 | if (attribute != att_function)
| 2-13 | ||||||||||||||||||||||||
| 292 | attribute &= ~att_function; /* so declare -xf works, for example */ executed 13 times by 1 test: attribute &= ~0x0000008;Executed by:
| 13 | ||||||||||||||||||||||||
| 293 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||||||||
| 294 | else | - | ||||||||||||||||||||||||
| 295 | variable_list = all_shell_variables (); executed 17 times by 1 test: variable_list = all_shell_variables ();Executed by:
| 17 | ||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 298 | if (attribute & att_array)
| 5-27 | ||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||
| 300 | arrays_only++; | - | ||||||||||||||||||||||||
| 301 | if (attribute != att_array)
| 1-4 | ||||||||||||||||||||||||
| 302 | attribute &= ~att_array; executed 1 time by 1 test: attribute &= ~0x0000004;Executed by:
| 1 | ||||||||||||||||||||||||
| 303 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 304 | else if (attribute & att_assoc)
| 7-20 | ||||||||||||||||||||||||
| 305 | { | - | ||||||||||||||||||||||||
| 306 | assoc_only++; | - | ||||||||||||||||||||||||
| 307 | if (attribute != att_assoc)
| 0-7 | ||||||||||||||||||||||||
| 308 | attribute &= ~att_assoc; never executed: attribute &= ~0x0000040; | 0 | ||||||||||||||||||||||||
| 309 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 310 | #endif | - | ||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | if (variable_list)
| 0-32 | ||||||||||||||||||||||||
| 313 | { | - | ||||||||||||||||||||||||
| 314 | for (i = 0; var = variable_list[i]; i++)
| 32-1188 | ||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||
| 316 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 317 | if (arrays_only && array_p (var) == 0)
| 92-706 | ||||||||||||||||||||||||
| 318 | continue; executed 390 times by 1 test: continue;Executed by:
| 390 | ||||||||||||||||||||||||
| 319 | else if (assoc_only && assoc_p (var) == 0)
| 25-438 | ||||||||||||||||||||||||
| 320 | continue; executed 413 times by 1 test: continue;Executed by:
| 413 | ||||||||||||||||||||||||
| 321 | #endif | - | ||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | /* If we imported a variable that's not a valid identifier, don't | - | ||||||||||||||||||||||||
| 324 | show it in any lists. */ | - | ||||||||||||||||||||||||
| 325 | if ((var->attributes & (att_invisible|att_imported)) == (att_invisible|att_imported))
| 0-385 | ||||||||||||||||||||||||
| 326 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | if ((var->attributes & attribute))
| 109-276 | ||||||||||||||||||||||||
| 329 | { | - | ||||||||||||||||||||||||
| 330 | show_var_attributes (var, READONLY_OR_EXPORT, nodefs); | - | ||||||||||||||||||||||||
| 331 | if (any_failed = sh_chkwrite (any_failed))
| 0-109 | ||||||||||||||||||||||||
| 332 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 333 | } executed 109 times by 1 test: end of blockExecuted by:
| 109 | ||||||||||||||||||||||||
| 334 | } executed 385 times by 1 test: end of blockExecuted by:
| 385 | ||||||||||||||||||||||||
| 335 | free (variable_list); | - | ||||||||||||||||||||||||
| 336 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 337 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | return (assign_error ? EX_BADASSIGN executed 2673 times by 1 test: return (assign_error ? 260 : ((any_failed == 0) ? 0 : 1));Executed by:
| 2673 | ||||||||||||||||||||||||
| 340 | : ((any_failed == 0) ? EXECUTION_SUCCESS executed 2673 times by 1 test: return (assign_error ? 260 : ((any_failed == 0) ? 0 : 1));Executed by:
| 2673 | ||||||||||||||||||||||||
| 341 | : EXECUTION_FAILURE)); executed 2673 times by 1 test: return (assign_error ? 260 : ((any_failed == 0) ? 0 : 1));Executed by:
| 2673 | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | /* Show all variable variables (v == 1) or functions (v == 0) with | - | ||||||||||||||||||||||||
| 345 | attributes. */ | - | ||||||||||||||||||||||||
| 346 | int | - | ||||||||||||||||||||||||
| 347 | show_all_var_attributes (v, nodefs) | - | ||||||||||||||||||||||||
| 348 | int v, nodefs; | - | ||||||||||||||||||||||||
| 349 | { | - | ||||||||||||||||||||||||
| 350 | SHELL_VAR **variable_list, *var; | - | ||||||||||||||||||||||||
| 351 | int any_failed; | - | ||||||||||||||||||||||||
| 352 | register int i; | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | variable_list = v ? all_shell_variables () : all_shell_functions ();
| 0 | ||||||||||||||||||||||||
| 355 | if (variable_list == 0)
| 0 | ||||||||||||||||||||||||
| 356 | return (EXECUTION_SUCCESS); never executed: return (0); | 0 | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | for (i = any_failed = 0; var = variable_list[i]; i++)
| 0 | ||||||||||||||||||||||||
| 359 | { | - | ||||||||||||||||||||||||
| 360 | show_var_attributes (var, READONLY_OR_EXPORT, nodefs); | - | ||||||||||||||||||||||||
| 361 | if (any_failed = sh_chkwrite (any_failed))
| 0 | ||||||||||||||||||||||||
| 362 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 364 | free (variable_list); | - | ||||||||||||||||||||||||
| 365 | return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE); never executed: return (any_failed == 0 ? 0 : 1); | 0 | ||||||||||||||||||||||||
| 366 | } | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | int | - | ||||||||||||||||||||||||
| 369 | var_attribute_string (var, pattr, flags) | - | ||||||||||||||||||||||||
| 370 | SHELL_VAR *var; | - | ||||||||||||||||||||||||
| 371 | int pattr; | - | ||||||||||||||||||||||||
| 372 | char *flags; /* filled in with attributes */ | - | ||||||||||||||||||||||||
| 373 | { | - | ||||||||||||||||||||||||
| 374 | int i; | - | ||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | i = 0; | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | /* pattr == 0 means we are called from `declare'. */ | - | ||||||||||||||||||||||||
| 379 | if (pattr == 0 || posixly_correct == 0)
| 3-578 | ||||||||||||||||||||||||
| 380 | { | - | ||||||||||||||||||||||||
| 381 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 382 | if (array_p (var))
| 240-347 | ||||||||||||||||||||||||
| 383 | flags[i++] = 'a'; executed 240 times by 1 test: flags[i++] = 'a';Executed by:
| 240 | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | if (assoc_p (var))
| 115-472 | ||||||||||||||||||||||||
| 386 | flags[i++] = 'A'; executed 115 times by 1 test: flags[i++] = 'A';Executed by:
| 115 | ||||||||||||||||||||||||
| 387 | #endif | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | if (function_p (var))
| 17-570 | ||||||||||||||||||||||||
| 390 | flags[i++] = 'f'; executed 17 times by 1 test: flags[i++] = 'f';Executed by:
| 17 | ||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | if (integer_p (var))
| 17-570 | ||||||||||||||||||||||||
| 393 | flags[i++] = 'i'; executed 17 times by 1 test: flags[i++] = 'i';Executed by:
| 17 | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | if (nameref_p (var))
| 95-492 | ||||||||||||||||||||||||
| 396 | flags[i++] = 'n'; executed 95 times by 1 test: flags[i++] = 'n';Executed by:
| 95 | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | if (readonly_p (var))
| 115-472 | ||||||||||||||||||||||||
| 399 | flags[i++] = 'r'; executed 115 times by 1 test: flags[i++] = 'r';Executed by:
| 115 | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | if (trace_p (var))
| 0-587 | ||||||||||||||||||||||||
| 402 | flags[i++] = 't'; never executed: flags[i++] = 't'; | 0 | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | if (exported_p (var))
| 36-551 | ||||||||||||||||||||||||
| 405 | flags[i++] = 'x'; executed 36 times by 1 test: flags[i++] = 'x';Executed by:
| 36 | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | if (capcase_p (var))
| 0-587 | ||||||||||||||||||||||||
| 408 | flags[i++] = 'c'; never executed: flags[i++] = 'c'; | 0 | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | if (lowercase_p (var))
| 6-581 | ||||||||||||||||||||||||
| 411 | flags[i++] = 'l'; executed 6 times by 1 test: flags[i++] = 'l';Executed by:
| 6 | ||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||
| 413 | if (uppercase_p (var))
| 0-587 | ||||||||||||||||||||||||
| 414 | flags[i++] = 'u'; never executed: flags[i++] = 'u'; | 0 | ||||||||||||||||||||||||
| 415 | } executed 587 times by 1 test: end of blockExecuted by:
| 587 | ||||||||||||||||||||||||
| 416 | else | - | ||||||||||||||||||||||||
| 417 | { | - | ||||||||||||||||||||||||
| 418 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 419 | if (array_p (var))
| 0-3 | ||||||||||||||||||||||||
| 420 | flags[i++] = 'a'; executed 3 times by 1 test: flags[i++] = 'a';Executed by:
| 3 | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | if (assoc_p (var))
| 0-3 | ||||||||||||||||||||||||
| 423 | flags[i++] = 'A'; never executed: flags[i++] = 'A'; | 0 | ||||||||||||||||||||||||
| 424 | #endif | - | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | if (function_p (var))
| 0-3 | ||||||||||||||||||||||||
| 427 | flags[i++] = 'f'; never executed: flags[i++] = 'f'; | 0 | ||||||||||||||||||||||||
| 428 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | flags[i] = '\0'; | - | ||||||||||||||||||||||||
| 431 | return i; executed 590 times by 1 test: return i;Executed by:
| 590 | ||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | /* Show the attributes for shell variable VAR. If NODEFS is non-zero, | - | ||||||||||||||||||||||||
| 435 | don't show function definitions along with the name. If PATTR is | - | ||||||||||||||||||||||||
| 436 | non-zero, it indicates we're being called from `export' or `readonly'. | - | ||||||||||||||||||||||||
| 437 | In POSIX mode, this prints the name of the calling builtin (`export' | - | ||||||||||||||||||||||||
| 438 | or `readonly') instead of `declare', and doesn't print function defs | - | ||||||||||||||||||||||||
| 439 | when called by `export' or `readonly'. */ | - | ||||||||||||||||||||||||
| 440 | int | - | ||||||||||||||||||||||||
| 441 | show_var_attributes (var, pattr, nodefs) | - | ||||||||||||||||||||||||
| 442 | SHELL_VAR *var; | - | ||||||||||||||||||||||||
| 443 | int pattr, nodefs; | - | ||||||||||||||||||||||||
| 444 | { | - | ||||||||||||||||||||||||
| 445 | char flags[MAX_ATTRIBUTES], *x; | - | ||||||||||||||||||||||||
| 446 | int i; | - | ||||||||||||||||||||||||
| 447 | - | |||||||||||||||||||||||||
| 448 | i = var_attribute_string (var, pattr, flags); | - | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | /* If we're printing functions with definitions, print the function def | - | ||||||||||||||||||||||||
| 451 | first, then the attributes, instead of printing output that can't be | - | ||||||||||||||||||||||||
| 452 | reused as input to recreate the current state. */ | - | ||||||||||||||||||||||||
| 453 | if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0))
| 0-559 | ||||||||||||||||||||||||
| 454 | { | - | ||||||||||||||||||||||||
| 455 | printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); | - | ||||||||||||||||||||||||
| 456 | nodefs++; | - | ||||||||||||||||||||||||
| 457 | if (pattr == 0 && i == 1 && flags[0] == 'f')
| 0-12 | ||||||||||||||||||||||||
| 458 | return 0; /* don't print `declare -f name' */ executed 12 times by 1 test: return 0;Executed by:
| 12 | ||||||||||||||||||||||||
| 459 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | if (pattr == 0 || posixly_correct == 0)
| 3-552 | ||||||||||||||||||||||||
| 462 | printf ("declare -%s ", i ? flags : "-"); executed 561 times by 1 test: printf ("declare -%s ", i ? flags : "-");Executed by:
| 561 | ||||||||||||||||||||||||
| 463 | else if (i)
| 0-3 | ||||||||||||||||||||||||
| 464 | printf ("%s -%s ", this_command_name, flags); executed 3 times by 1 test: printf ("%s -%s ", this_command_name, flags);Executed by:
| 3 | ||||||||||||||||||||||||
| 465 | else | - | ||||||||||||||||||||||||
| 466 | printf ("%s ", this_command_name); never executed: printf ("%s ", this_command_name); | 0 | ||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||||||||
| 469 | if (invisible_p (var) && (array_p (var) || assoc_p (var)))
| 7-518 | ||||||||||||||||||||||||
| 470 | printf ("%s\n", var->name); executed 23 times by 1 test: printf ("%s\n", var->name);Executed by:
| 23 | ||||||||||||||||||||||||
| 471 | else if (array_p (var))
| 222-319 | ||||||||||||||||||||||||
| 472 | print_array_assignment (var, 0); executed 222 times by 1 test: print_array_assignment (var, 0);Executed by:
| 222 | ||||||||||||||||||||||||
| 473 | else if (assoc_p (var))
| 105-214 | ||||||||||||||||||||||||
| 474 | print_assoc_assignment (var, 0); executed 105 times by 1 test: print_assoc_assignment (var, 0);Executed by:
| 105 | ||||||||||||||||||||||||
| 475 | else | - | ||||||||||||||||||||||||
| 476 | #endif | - | ||||||||||||||||||||||||
| 477 | /* force `readonly' and `export' to not print out function definitions | - | ||||||||||||||||||||||||
| 478 | when in POSIX mode. */ | - | ||||||||||||||||||||||||
| 479 | if (nodefs || (function_p (var) && pattr != 0 && posixly_correct))
| 0-209 | ||||||||||||||||||||||||
| 480 | printf ("%s\n", var->name); executed 5 times by 1 test: printf ("%s\n", var->name);Executed by:
| 5 | ||||||||||||||||||||||||
| 481 | else if (function_p (var))
| 0-209 | ||||||||||||||||||||||||
| 482 | printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); never executed: printf ("%s\n", named_function_string (var->name, (COMMAND *)((var)->value), 0x01|0x02)); | 0 | ||||||||||||||||||||||||
| 483 | else if (invisible_p (var) || var_isset (var) == 0)
| 1-186 | ||||||||||||||||||||||||
| 484 | printf ("%s\n", var->name); executed 24 times by 1 test: printf ("%s\n", var->name);Executed by:
| 24 | ||||||||||||||||||||||||
| 485 | else | - | ||||||||||||||||||||||||
| 486 | { | - | ||||||||||||||||||||||||
| 487 | x = sh_double_quote (value_cell (var)); | - | ||||||||||||||||||||||||
| 488 | printf ("%s=%s\n", var->name, x); | - | ||||||||||||||||||||||||
| 489 | free (x); | - | ||||||||||||||||||||||||
| 490 | } executed 185 times by 1 test: end of blockExecuted by:
| 185 | ||||||||||||||||||||||||
| 491 | return (0); executed 564 times by 1 test: return (0);Executed by:
| 564 | ||||||||||||||||||||||||
| 492 | } | - | ||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | int | - | ||||||||||||||||||||||||
| 495 | show_name_attributes (name, nodefs) | - | ||||||||||||||||||||||||
| 496 | char *name; | - | ||||||||||||||||||||||||
| 497 | int nodefs; | - | ||||||||||||||||||||||||
| 498 | { | - | ||||||||||||||||||||||||
| 499 | SHELL_VAR *var; | - | ||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||
| 501 | #if 0 | - | ||||||||||||||||||||||||
| 502 | var = find_variable_tempenv (name); | - | ||||||||||||||||||||||||
| 503 | #else | - | ||||||||||||||||||||||||
| 504 | var = find_variable_noref (name); | - | ||||||||||||||||||||||||
| 505 | #endif | - | ||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | if (var /* && invisible_p (var) == 0 */) /* XXX bash-4.4/bash-5.0 */
| 51-461 | ||||||||||||||||||||||||
| 508 | { | - | ||||||||||||||||||||||||
| 509 | show_var_attributes (var, READONLY_OR_EXPORT, nodefs); | - | ||||||||||||||||||||||||
| 510 | return (0); executed 461 times by 1 test: return (0);Executed by:
| 461 | ||||||||||||||||||||||||
| 511 | } | - | ||||||||||||||||||||||||
| 512 | else | - | ||||||||||||||||||||||||
| 513 | return (1); executed 51 times by 1 test: return (1);Executed by:
| 51 | ||||||||||||||||||||||||
| 514 | } | - | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | int | - | ||||||||||||||||||||||||
| 517 | show_func_attributes (name, nodefs) | - | ||||||||||||||||||||||||
| 518 | char *name; | - | ||||||||||||||||||||||||
| 519 | int nodefs; | - | ||||||||||||||||||||||||
| 520 | { | - | ||||||||||||||||||||||||
| 521 | SHELL_VAR *var; | - | ||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | var = find_function (name); | - | ||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | if (var)
| 2-6 | ||||||||||||||||||||||||
| 526 | { | - | ||||||||||||||||||||||||
| 527 | show_var_attributes (var, READONLY_OR_EXPORT, nodefs); | - | ||||||||||||||||||||||||
| 528 | return (0); executed 6 times by 1 test: return (0);Executed by:
| 6 | ||||||||||||||||||||||||
| 529 | } | - | ||||||||||||||||||||||||
| 530 | else | - | ||||||||||||||||||||||||
| 531 | return (1); executed 2 times by 1 test: return (1);Executed by:
| 2 | ||||||||||||||||||||||||
| 532 | } | - | ||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | void | - | ||||||||||||||||||||||||
| 535 | set_var_attribute (name, attribute, undo) | - | ||||||||||||||||||||||||
| 536 | char *name; | - | ||||||||||||||||||||||||
| 537 | int attribute, undo; | - | ||||||||||||||||||||||||
| 538 | { | - | ||||||||||||||||||||||||
| 539 | SHELL_VAR *var, *tv, *v, *refvar; | - | ||||||||||||||||||||||||
| 540 | char *tvalue; | - | ||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||
| 542 | if (undo)
| 5-2593 | ||||||||||||||||||||||||
| 543 | var = find_variable (name); executed 5 times by 1 test: var = find_variable (name);Executed by:
| 5 | ||||||||||||||||||||||||
| 544 | else | - | ||||||||||||||||||||||||
| 545 | { | - | ||||||||||||||||||||||||
| 546 | tv = find_tempenv_variable (name); | - | ||||||||||||||||||||||||
| 547 | /* XXX -- need to handle case where tv is a temp variable in a | - | ||||||||||||||||||||||||
| 548 | function-scope context, since function_env has been merged into | - | ||||||||||||||||||||||||
| 549 | the local variables table. */ | - | ||||||||||||||||||||||||
| 550 | if (tv && tempvar_p (tv))
| 0-2586 | ||||||||||||||||||||||||
| 551 | { | - | ||||||||||||||||||||||||
| 552 | tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring ("");
| 0-7 | ||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | var = bind_variable (tv->name, tvalue, 0); | - | ||||||||||||||||||||||||
| 555 | if (var == 0)
| 0-7 | ||||||||||||||||||||||||
| 556 | { | - | ||||||||||||||||||||||||
| 557 | free (tvalue); | - | ||||||||||||||||||||||||
| 558 | return; /* XXX - no error message here */ never executed: return; | 0 | ||||||||||||||||||||||||
| 559 | } | - | ||||||||||||||||||||||||
| 560 | var->attributes |= tv->attributes & ~att_tempvar; | - | ||||||||||||||||||||||||
| 561 | /* This avoids an error message when propagating a read-only var | - | ||||||||||||||||||||||||
| 562 | later on. */ | - | ||||||||||||||||||||||||
| 563 | if (var->context == 0 && (attribute & att_readonly))
| 0-7 | ||||||||||||||||||||||||
| 564 | { | - | ||||||||||||||||||||||||
| 565 | /* Don't bother to set the `propagate to the global variables | - | ||||||||||||||||||||||||
| 566 | table' flag if we've just bound the variable in that table */ | - | ||||||||||||||||||||||||
| 567 | v = find_global_variable (tv->name); | - | ||||||||||||||||||||||||
| 568 | if (v != var)
| 0 | ||||||||||||||||||||||||
| 569 | VSETATTR (tv, att_propagate); never executed: ((tv)->attributes |= (0x0200000)); | 0 | ||||||||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 571 | else | - | ||||||||||||||||||||||||
| 572 | VSETATTR (tv, att_propagate); executed 7 times by 1 test: ((tv)->attributes |= (0x0200000));Executed by:
| 7 | ||||||||||||||||||||||||
| 573 | if (var->context != 0)
| 0-7 | ||||||||||||||||||||||||
| 574 | VSETATTR (var, att_propagate); never executed: ((var)->attributes |= (0x0200000)); | 0 | ||||||||||||||||||||||||
| 575 | SETVARATTR (tv, attribute, undo); /* XXX */ | - | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | stupidly_hack_special_variables (tv->name); | - | ||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||
| 579 | free (tvalue); | - | ||||||||||||||||||||||||
| 580 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 581 | else | - | ||||||||||||||||||||||||
| 582 | { | - | ||||||||||||||||||||||||
| 583 | var = find_variable_notempenv (name); | - | ||||||||||||||||||||||||
| 584 | if (var == 0)
| 6-2580 | ||||||||||||||||||||||||
| 585 | { | - | ||||||||||||||||||||||||
| 586 | /* We might have a nameref pointing to something that we can't | - | ||||||||||||||||||||||||
| 587 | resolve to a shell variable. If we do, skip it. We do a little | - | ||||||||||||||||||||||||
| 588 | checking just so we can print an error message. */ | - | ||||||||||||||||||||||||
| 589 | refvar = find_variable_nameref_for_create (name, 0); | - | ||||||||||||||||||||||||
| 590 | if (refvar == INVALID_NAMEREF_VALUE)
| 1-5 | ||||||||||||||||||||||||
| 591 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||
| 592 | /* Otherwise we probably have a nameref pointing to a variable | - | ||||||||||||||||||||||||
| 593 | that hasn't been created yet. bind_variable will take care | - | ||||||||||||||||||||||||
| 594 | of that. */ | - | ||||||||||||||||||||||||
| 595 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 596 | if (var == 0)
| 5-2580 | ||||||||||||||||||||||||
| 597 | { | - | ||||||||||||||||||||||||
| 598 | var = bind_variable (name, (char *)NULL, 0); | - | ||||||||||||||||||||||||
| 599 | if (var && no_invisible_vars == 0)
| 0-5 | ||||||||||||||||||||||||
| 600 | VSETATTR (var, att_invisible); executed 5 times by 1 test: ((var)->attributes |= (0x0001000));Executed by:
| 5 | ||||||||||||||||||||||||
| 601 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 602 | else if (var->context != 0)
| 8-2572 | ||||||||||||||||||||||||
| 603 | VSETATTR (var, att_propagate); executed 8 times by 1 test: ((var)->attributes |= (0x0200000));Executed by:
| 8 | ||||||||||||||||||||||||
| 604 | } executed 2585 times by 1 test: end of blockExecuted by:
| 2585 | ||||||||||||||||||||||||
| 605 | } | - | ||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||
| 607 | if (var)
| 0-2597 | ||||||||||||||||||||||||
| 608 | SETVARATTR (var, attribute, undo); executed 2597 times by 1 test: ((undo == 0) ? ((var)->attributes |= (attribute)) : ((var)->attributes &= ~(attribute)));Executed by:
| 2597 | ||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||
| 610 | if (var && (exported_p (var) || (attribute & att_exported)))
| 0-2597 | ||||||||||||||||||||||||
| 611 | array_needs_making++; /* XXX */ executed 2519 times by 1 test: array_needs_making++;Executed by:
| 2519 | ||||||||||||||||||||||||
| 612 | } executed 2597 times by 1 test: end of blockExecuted by:
| 2597 | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |