OpenCoverage

variables.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/variables.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* variables.c -- Functions for hacking shell variables. */-
2-
3/* Copyright (C) 1987-2018 Free Software Foundation, Inc.-
4-
5 This file is part of GNU Bash, the Bourne Again SHell.-
6-
7 Bash is free software: you can redistribute it and/or modify-
8 it under the terms of the GNU General Public License as published by-
9 the Free Software Foundation, either version 3 of the License, or-
10 (at your option) any later version.-
11-
12 Bash is distributed in the hope that it will be useful,-
13 but WITHOUT ANY WARRANTY; without even the implied warranty of-
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
15 GNU General Public License for more details.-
16-
17 You should have received a copy of the GNU General Public License-
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.-
19*/-
20-
21#include "config.h"-
22-
23#include "bashtypes.h"-
24#include "posixstat.h"-
25#include "posixtime.h"-
26-
27#if defined (__QNX__)-
28# if defined (__QNXNTO__)-
29# include <sys/netmgr.h>-
30# else-
31# include <sys/vc.h>-
32# endif /* !__QNXNTO__ */-
33#endif /* __QNX__ */-
34-
35#if defined (HAVE_UNISTD_H)-
36# include <unistd.h>-
37#endif-
38-
39#include <stdio.h>-
40#include "chartypes.h"-
41#if defined (HAVE_PWD_H)-
42# include <pwd.h>-
43#endif-
44#include "bashansi.h"-
45#include "bashintl.h"-
46-
47#define NEED_XTRACE_SET_DECL-
48-
49#include "shell.h"-
50#include "parser.h"-
51#include "flags.h"-
52#include "execute_cmd.h"-
53#include "findcmd.h"-
54#include "mailcheck.h"-
55#include "input.h"-
56#include "hashcmd.h"-
57#include "pathexp.h"-
58#include "alias.h"-
59#include "jobs.h"-
60-
61#include "version.h"-
62-
63#include "builtins/getopt.h"-
64#include "builtins/common.h"-
65#include "builtins/builtext.h"-
66-
67#if defined (READLINE)-
68# include "bashline.h"-
69# include <readline/readline.h>-
70#else-
71# include <tilde/tilde.h>-
72#endif-
73-
74#if defined (HISTORY)-
75# include "bashhist.h"-
76# include <readline/history.h>-
77#endif /* HISTORY */-
78-
79#if defined (PROGRAMMABLE_COMPLETION)-
80# include "pcomplete.h"-
81#endif-
82-
83#define VARIABLES_HASH_BUCKETS 1024 /* must be power of two */-
84#define FUNCTIONS_HASH_BUCKETS 512-
85#define TEMPENV_HASH_BUCKETS 4 /* must be power of two */-
86-
87#define BASHFUNC_PREFIX "BASH_FUNC_"-
88#define BASHFUNC_PREFLEN 10 /* == strlen(BASHFUNC_PREFIX */-
89#define BASHFUNC_SUFFIX "%%"-
90#define BASHFUNC_SUFFLEN 2 /* == strlen(BASHFUNC_SUFFIX) */-
91-
92/* flags for find_variable_internal */-
93-
94#define FV_FORCETEMPENV 0x01-
95#define FV_SKIPINVISIBLE 0x02-
96-
97extern char **environ;-
98-
99/* Variables used here and defined in other files. */-
100extern time_t shell_start_time;-
101-
102/* The list of shell variables that the user has created at the global-
103 scope, or that came from the environment. */-
104VAR_CONTEXT *global_variables = (VAR_CONTEXT *)NULL;-
105-
106/* The current list of shell variables, including function scopes */-
107VAR_CONTEXT *shell_variables = (VAR_CONTEXT *)NULL;-
108-
109/* The list of shell functions that the user has created, or that came from-
110 the environment. */-
111HASH_TABLE *shell_functions = (HASH_TABLE *)NULL;-
112-
113#if defined (DEBUGGER)-
114/* The table of shell function definitions that the user defined or that-
115 came from the environment. */-
116HASH_TABLE *shell_function_defs = (HASH_TABLE *)NULL;-
117#endif-
118-
119/* The current variable context. This is really a count of how deep into-
120 executing functions we are. */-
121int variable_context = 0;-
122-
123/* If non-zero, local variables inherit values and attributes from a variable-
124 with the same name at a previous scope. */-
125int localvar_inherit = 0;-
126-
127/* If non-zero, calling `unset' on local variables in previous scopes marks-
128 them as invisible so lookups find them unset. This is the same behavior-
129 as local variables in the current local scope. */-
130int localvar_unset = 0;-
131-
132/* The set of shell assignments which are made only in the environment-
133 for a single command. */-
134HASH_TABLE *temporary_env = (HASH_TABLE *)NULL;-
135-
136/* Set to non-zero if an assignment error occurs while putting variables-
137 into the temporary environment. */-
138int tempenv_assign_error;-
139-
140/* Some funky variables which are known about specially. Here is where-
141 "$*", "$1", and all the cruft is kept. */-
142char *dollar_vars[10];-
143WORD_LIST *rest_of_args = (WORD_LIST *)NULL;-
144-
145/* The value of $$. */-
146pid_t dollar_dollar_pid;-
147-
148/* Non-zero means that we have to remake EXPORT_ENV. */-
149int array_needs_making = 1;-
150-
151/* The number of times BASH has been executed. This is set-
152 by initialize_variables (). */-
153int shell_level = 0;-
154-
155/* An array which is passed to commands as their environment. It is-
156 manufactured from the union of the initial environment and the-
157 shell variables that are marked for export. */-
158char **export_env = (char **)NULL;-
159static int export_env_index;-
160static int export_env_size;-
161-
162#if defined (READLINE)-
163static int winsize_assignment; /* currently assigning to LINES or COLUMNS */-
164#endif-
165-
166SHELL_VAR nameref_invalid_value;-
167static SHELL_VAR nameref_maxloop_value;-
168-
169static HASH_TABLE *last_table_searched; /* hash_lookup sets this */-
170-
171/* Some forward declarations. */-
172static void create_variable_tables __P((void));-
173-
174static void set_machine_vars __P((void));-
175static void set_home_var __P((void));-
176static void set_shell_var __P((void));-
177static char *get_bash_name __P((void));-
178static void initialize_shell_level __P((void));-
179static void uidset __P((void));-
180#if defined (ARRAY_VARS)-
181static void make_vers_array __P((void));-
182#endif-
183-
184static SHELL_VAR *null_assign __P((SHELL_VAR *, char *, arrayind_t, char *));-
185#if defined (ARRAY_VARS)-
186static SHELL_VAR *null_array_assign __P((SHELL_VAR *, char *, arrayind_t, char *));-
187#endif-
188static SHELL_VAR *get_self __P((SHELL_VAR *));-
189-
190#if defined (ARRAY_VARS)-
191static SHELL_VAR *init_dynamic_array_var __P((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int));-
192static SHELL_VAR *init_dynamic_assoc_var __P((char *, sh_var_value_func_t *, sh_var_assign_func_t *, int));-
193#endif-
194-
195static SHELL_VAR *assign_seconds __P((SHELL_VAR *, char *, arrayind_t, char *));-
196static SHELL_VAR *get_seconds __P((SHELL_VAR *));-
197static SHELL_VAR *init_seconds_var __P((void));-
198-
199static int brand __P((void));-
200static void sbrand __P((unsigned long)); /* set bash random number generator. */-
201static void seedrand __P((void)); /* seed generator randomly */-
202static SHELL_VAR *assign_random __P((SHELL_VAR *, char *, arrayind_t, char *));-
203static SHELL_VAR *get_random __P((SHELL_VAR *));-
204-
205static SHELL_VAR *assign_lineno __P((SHELL_VAR *, char *, arrayind_t, char *));-
206static SHELL_VAR *get_lineno __P((SHELL_VAR *));-
207-
208static SHELL_VAR *assign_subshell __P((SHELL_VAR *, char *, arrayind_t, char *));-
209static SHELL_VAR *get_subshell __P((SHELL_VAR *));-
210-
211static SHELL_VAR *get_epochseconds __P((SHELL_VAR *));-
212static SHELL_VAR *get_epochrealtime __P((SHELL_VAR *));-
213-
214static SHELL_VAR *get_bashpid __P((SHELL_VAR *));-
215-
216#if defined (HISTORY)-
217static SHELL_VAR *get_histcmd __P((SHELL_VAR *));-
218#endif-
219-
220#if defined (READLINE)-
221static SHELL_VAR *get_comp_wordbreaks __P((SHELL_VAR *));-
222static SHELL_VAR *assign_comp_wordbreaks __P((SHELL_VAR *, char *, arrayind_t, char *));-
223#endif-
224-
225#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)-
226static SHELL_VAR *assign_dirstack __P((SHELL_VAR *, char *, arrayind_t, char *));-
227static SHELL_VAR *get_dirstack __P((SHELL_VAR *));-
228#endif-
229-
230#if defined (ARRAY_VARS)-
231static SHELL_VAR *get_groupset __P((SHELL_VAR *));-
232-
233static SHELL_VAR *build_hashcmd __P((SHELL_VAR *));-
234static SHELL_VAR *get_hashcmd __P((SHELL_VAR *));-
235static SHELL_VAR *assign_hashcmd __P((SHELL_VAR *, char *, arrayind_t, char *));-
236# if defined (ALIAS)-
237static SHELL_VAR *build_aliasvar __P((SHELL_VAR *));-
238static SHELL_VAR *get_aliasvar __P((SHELL_VAR *));-
239static SHELL_VAR *assign_aliasvar __P((SHELL_VAR *, char *, arrayind_t, char *));-
240# endif-
241#endif-
242-
243static SHELL_VAR *get_funcname __P((SHELL_VAR *));-
244static SHELL_VAR *init_funcname_var __P((void));-
245-
246static void initialize_dynamic_variables __P((void));-
247-
248static SHELL_VAR *hash_lookup __P((const char *, HASH_TABLE *));-
249static SHELL_VAR *new_shell_variable __P((const char *));-
250static SHELL_VAR *make_new_variable __P((const char *, HASH_TABLE *));-
251static SHELL_VAR *bind_variable_internal __P((const char *, char *, HASH_TABLE *, int, int));-
252-
253static void dispose_variable_value __P((SHELL_VAR *));-
254static void free_variable_hash_data __P((PTR_T));-
255-
256static VARLIST *vlist_alloc __P((int));-
257static VARLIST *vlist_realloc __P((VARLIST *, int));-
258static void vlist_add __P((VARLIST *, SHELL_VAR *, int));-
259-
260static void flatten __P((HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int));-
261-
262static int qsort_var_comp __P((SHELL_VAR **, SHELL_VAR **));-
263-
264static SHELL_VAR **vapply __P((sh_var_map_func_t *));-
265static SHELL_VAR **fapply __P((sh_var_map_func_t *));-
266-
267static int visible_var __P((SHELL_VAR *));-
268static int visible_and_exported __P((SHELL_VAR *));-
269static int export_environment_candidate __P((SHELL_VAR *));-
270static int local_and_exported __P((SHELL_VAR *));-
271static int variable_in_context __P((SHELL_VAR *));-
272#if defined (ARRAY_VARS)-
273static int visible_array_vars __P((SHELL_VAR *));-
274#endif-
275-
276static SHELL_VAR *find_variable_internal __P((const char *, int));-
277-
278static SHELL_VAR *find_nameref_at_context __P((SHELL_VAR *, VAR_CONTEXT *));-
279static SHELL_VAR *find_variable_nameref_context __P((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **));-
280static SHELL_VAR *find_variable_last_nameref_context __P((SHELL_VAR *, VAR_CONTEXT *, VAR_CONTEXT **));-
281-
282static SHELL_VAR *bind_tempenv_variable __P((const char *, char *));-
283static void push_temp_var __P((PTR_T));-
284static void propagate_temp_var __P((PTR_T));-
285static void dispose_temporary_env __P((sh_free_func_t *)); -
286-
287static inline char *mk_env_string __P((const char *, const char *, int));-
288static char **make_env_array_from_var_list __P((SHELL_VAR **));-
289static char **make_var_export_array __P((VAR_CONTEXT *));-
290static char **make_func_export_array __P((void));-
291static void add_temp_array_to_env __P((char **, int, int));-
292-
293static int n_shell_variables __P((void));-
294static int set_context __P((SHELL_VAR *));-
295-
296static void push_func_var __P((PTR_T));-
297static void push_exported_var __P((PTR_T));-
298-
299static inline int find_special_var __P((const char *));-
300-
301static void-
302create_variable_tables ()-
303{-
304 if (shell_variables == 0)
shell_variables == 0Description
TRUEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-5432
305 {-
306 shell_variables = global_variables = new_var_context ((char *)NULL, 0);-
307 shell_variables->scope = 0;-
308 shell_variables->table = hash_create (VARIABLES_HASH_BUCKETS);-
309 }
executed 5432 times by 1 test: end of block
Executed by:
  • Self test
5432
310-
311 if (shell_functions == 0)
shell_functions == 0Description
TRUEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-5432
312 shell_functions = hash_create (FUNCTIONS_HASH_BUCKETS);
executed 5432 times by 1 test: shell_functions = hash_create (512);
Executed by:
  • Self test
5432
313-
314#if defined (DEBUGGER)-
315 if (shell_function_defs == 0)
shell_function_defs == 0Description
TRUEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-5432
316 shell_function_defs = hash_create (FUNCTIONS_HASH_BUCKETS);
executed 5432 times by 1 test: shell_function_defs = hash_create (512);
Executed by:
  • Self test
5432
317#endif-
318}
executed 5464 times by 1 test: end of block
Executed by:
  • Self test
5464
319-
320/* Initialize the shell variables from the current environment.-
321 If PRIVMODE is nonzero, don't import functions from ENV or-
322 parse $SHELLOPTS. */-
323void-
324initialize_shell_variables (env, privmode)-
325 char **env;-
326 int privmode;-
327{-
328 char *name, *string, *temp_string;-
329 int c, char_index, string_index, string_length, ro;-
330 SHELL_VAR *temp_var;-
331-
332 create_variable_tables ();-
333-
334 for (string_index = 0; env && (string = env[string_index++]); )
envDescription
TRUEevaluated 131099 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string = env[string_index++])Description
TRUEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-131099
335 {-
336 char_index = 0;-
337 name = string;-
338 while ((c = *string++) && c != '=')
(c = *string++)Description
TRUEevaluated 1108719 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c != '='Description
TRUEevaluated 983067 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
0-1108719
339 ;
executed 983067 times by 1 test: ;
Executed by:
  • Self test
983067
340 if (string[-1] == '=')
string[-1] == '='Description
TRUEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-125652
341 char_index = string - name - 1;
executed 125652 times by 1 test: char_index = string - name - 1;
Executed by:
  • Self test
125652
342-
343 /* If there are weird things in the environment, like `=xxx' or a-
344 string without an `=', just skip them. */-
345 if (char_index == 0)
char_index == 0Description
TRUEnever evaluated
FALSEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
0-125652
346 continue;
never executed: continue;
0
347-
348 /* ASSERT(name[char_index] == '=') */-
349 name[char_index] = '\0';-
350 /* Now, name = env variable name, string = env variable value, and-
351 char_index == strlen (name) */-
352-
353 temp_var = (SHELL_VAR *)NULL;-
354-
355#if defined (FUNCTION_IMPORT)-
356 /* If exported function, define it now. Don't import functions from-
357 the environment in privileged mode. */-
358 if (privmode == 0 && read_but_dont_execute == 0 &&
privmode == 0Description
TRUEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
read_but_dont_execute == 0Description
TRUEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-125652
359 STREQN (BASHFUNC_PREFIX, name, BASHFUNC_PREFLEN) &&
never executed: __result = (((const unsigned char *) (const char *) ( "BASH_FUNC_" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(10 == 0)Description
TRUEnever evaluated
FALSEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
((10 == 0) ? (... 10 ))) == 0))Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 125591 times by 1 test
Evaluated by:
  • Self test
("BASH_FUNC_")[0] == (name)[0]Description
TRUEevaluated 5505 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 120147 times by 1 test
Evaluated by:
  • Self test
(__extension__... , 10 ))) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( 10 )Description
TRUEevaluated 5505 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons..."BASH_FUNC_" )Description
TRUEevaluated 5505 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "BASH...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEevaluated 5505 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEevaluated 5505 times by 1 test
Evaluated by:
  • Self test
strlen ( name ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-125652
360 STREQ (BASHFUNC_SUFFIX, name + char_index - BASHFUNC_SUFFLEN) &&
never executed: __result = (((const unsigned char *) (const char *) ( "%%" ))[3] - __s2[3]);
executed 61 times by 1 test: end of block
Executed by:
  • Self test
executed 61 times by 1 test: end of block
Executed by:
  • Self test
never executed: __result = (((const unsigned char *) (const char *) ( name + char_index - 2 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
("%%")[0] == (..._index - 2)[0]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 1Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__result == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-61
361 STREQN ("() {", string, 4))
never executed: __result = (((const unsigned char *) (const char *) ( "() {" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( string ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(4 == 0)Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
((4 == 0) ? (1..., 4 ))) == 0))Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
("() {")[0] == (string)[0]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(__extension__...g , 4 ))) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_constant_p ( 4 )Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...t_p ( "() {" )Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
strlen ( "() {...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( string )Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
strlen ( strin...size_t) ( 4 ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-61
362 {-
363 size_t namelen;-
364 char *tname; /* desired imported function name */-
365-
366 namelen = char_index - BASHFUNC_PREFLEN - BASHFUNC_SUFFLEN;-
367-
368 tname = name + BASHFUNC_PREFLEN; /* start of func name */-
369 tname[namelen] = '\0'; /* now tname == func name */-
370-
371 string_length = strlen (string);-
372 temp_string = (char *)xmalloc (namelen + string_length + 2);-
373-
374 memcpy (temp_string, tname, namelen);-
375 temp_string[namelen] = ' ';-
376 memcpy (temp_string + namelen + 1, string, string_length + 1);-
377-
378 /* Don't import function names that are invalid identifiers from the-
379 environment in posix mode, though we still allow them to be defined as-
380 shell variables. */-
381 if (absolute_program (tname) == 0 && (posixly_correct == 0 || legal_identifier (tname)))
absolute_program (tname) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correct == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
legal_identifier (tname)Description
TRUEnever evaluated
FALSEnever evaluated
0-61
382 parse_and_execute (temp_string, tname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
executed 61 times by 1 test: parse_and_execute (temp_string, tname, 0x001|0x004|0x080|0x100);
Executed by:
  • Self test
61
383 else-
384 free (temp_string); /* parse_and_execute does this */
never executed: sh_xfree((temp_string), "variables.c", 384);
0
385-
386 if (temp_var = find_function (tname))
temp_var = fin...nction (tname)Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-49
387 {-
388 VSETATTR (temp_var, (att_exported|att_imported));-
389 array_needs_making = 1;-
390 }
executed 49 times by 1 test: end of block
Executed by:
  • Self test
49
391 else-
392 {-
393 if (temp_var = bind_variable (name, string, 0))
temp_var = bin...me, string, 0)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
394 {-
395 VSETATTR (temp_var, (att_exported | att_imported | att_invisible));-
396 array_needs_making = 1;-
397 }
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
398 last_command_exit_value = 1;-
399 report_error (_("error importing function definition for `%s'"), tname);-
400 }
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
401-
402 /* Restore original suffix */-
403 tname[namelen] = BASHFUNC_SUFFIX[0];-
404 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
405 else-
406#endif /* FUNCTION_IMPORT */-
407#if defined (ARRAY_VARS)-
408# if ARRAY_EXPORT-
409 /* Array variables may not yet be exported. */-
410 if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')-
411 {-
412 string_length = 1;-
413 temp_string = extract_array_assignment_list (string, &string_length);-
414 temp_var = assign_array_from_string (name, temp_string, 0);-
415 FREE (temp_string);-
416 VSETATTR (temp_var, (att_exported | att_imported));-
417 array_needs_making = 1;-
418 }-
419 else-
420# endif /* ARRAY_EXPORT */-
421#endif-
422 {-
423 ro = 0;-
424 /* If we processed a command-line option that caused SHELLOPTS to be-
425 set, it may already be set (and read-only) by the time we process-
426 the shell's environment. */-
427 if (/* posixly_correct &&*/ STREQ (name, "SHELLOPTS"))
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "SHELLOPTS" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(name)[0] == ("SHELLOPTS")[0]Description
TRUEevaluated 10888 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114703 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEevaluated 10888 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-114703
428 {-
429 temp_var = find_variable ("SHELLOPTS");-
430 ro = temp_var && readonly_p (temp_var);
temp_varDescription
TRUEnever evaluated
FALSEnever evaluated
((((temp_var)-... (0x0000002)))Description
TRUEnever evaluated
FALSEnever evaluated
0
431 if (temp_var)
temp_varDescription
TRUEnever evaluated
FALSEnever evaluated
0
432 VUNSETATTR (temp_var, att_readonly);
never executed: ((temp_var)->attributes &= ~(0x0000002));
0
433 }
never executed: end of block
0
434 temp_var = bind_variable (name, string, 0);-
435 if (temp_var)
temp_varDescription
TRUEevaluated 125591 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-125591
436 {-
437 if (legal_identifier (name))
legal_identifier (name)Description
TRUEevaluated 125591 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-125591
438 VSETATTR (temp_var, (att_exported | att_imported));
executed 125591 times by 1 test: ((temp_var)->attributes |= ((0x0000001 | 0x0008000)));
Executed by:
  • Self test
125591
439 else-
440 VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
never executed: ((temp_var)->attributes |= ((0x0000001 | 0x0008000 | 0x0001000)));
0
441 if (ro)
roDescription
TRUEnever evaluated
FALSEevaluated 125591 times by 1 test
Evaluated by:
  • Self test
0-125591
442 VSETATTR (temp_var, att_readonly);
never executed: ((temp_var)->attributes |= (0x0000002));
0
443 array_needs_making = 1;-
444 }
executed 125591 times by 1 test: end of block
Executed by:
  • Self test
125591
445 }
executed 125591 times by 1 test: end of block
Executed by:
  • Self test
125591
446-
447 name[char_index] = '=';-
448 /* temp_var can be NULL if it was an exported function with a syntax-
449 error (a different bug, but it still shouldn't dump core). */-
450 if (temp_var && function_p (temp_var) == 0) /* XXX not yet */
temp_varDescription
TRUEevaluated 125652 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((temp_var)-...000008))) == 0Description
TRUEevaluated 125603 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
0-125652
451 {-
452 CACHE_IMPORTSTR (temp_var, name);-
453 }
executed 125603 times by 1 test: end of block
Executed by:
  • Self test
125603
454 }
executed 125652 times by 1 test: end of block
Executed by:
  • Self test
125652
455-
456 set_pwd ();-
457-
458 /* Set up initial value of $_ */-
459 temp_var = set_if_not ("_", dollar_vars[0]);-
460-
461 /* Remember this pid. */-
462 dollar_dollar_pid = getpid ();-
463-
464 /* Now make our own defaults in case the vars that we think are-
465 important are missing. */-
466 temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE);-
467 temp_var = set_if_not ("TERM", "dumb");-
468-
469#if defined (__QNX__)-
470 /* set node id -- don't import it from the environment */-
471 {-
472 char node_name[22];-
473# if defined (__QNXNTO__)-
474 netmgr_ndtostr(ND2S_LOCAL_STR, ND_LOCAL_NODE, node_name, sizeof(node_name));-
475# else-
476 qnx_nidtostr (getnid (), node_name, sizeof (node_name));-
477# endif-
478 temp_var = bind_variable ("NODE", node_name, 0);-
479 if (temp_var)-
480 set_auto_export (temp_var);-
481 }-
482#endif-
483-
484 /* set up the prompts. */-
485 if (interactive_shell)
interactive_shellDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5445 times by 1 test
Evaluated by:
  • Self test
2-5445
486 {-
487#if defined (PROMPT_STRING_DECODE)-
488 set_if_not ("PS1", primary_prompt);-
489#else-
490 if (current_user.uid == -1)-
491 get_current_user_info ();-
492 set_if_not ("PS1", current_user.euid == 0 ? "# " : primary_prompt);-
493#endif-
494 set_if_not ("PS2", secondary_prompt);-
495 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
496-
497 if (current_user.euid == 0)
current_user.euid == 0Description
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
498 bind_variable ("PS4", "+ ", 0);
never executed: bind_variable ("PS4", "+ ", 0);
0
499 else-
500 set_if_not ("PS4", "+ ");
executed 5447 times by 1 test: set_if_not ("PS4", "+ ");
Executed by:
  • Self test
5447
501-
502 /* Don't allow IFS to be imported from the environment. */-
503 temp_var = bind_variable ("IFS", " \t\n", 0);-
504 setifs (temp_var);-
505-
506 /* Magic machine types. Pretty convenient. */-
507 set_machine_vars ();-
508-
509 /* Default MAILCHECK for interactive shells. Defer the creation of a-
510 default MAILPATH until the startup files are read, because MAIL-
511 names a mail file if MAILPATH is not set, and we should provide a-
512 default only if neither is set. */-
513 if (interactive_shell)
interactive_shellDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5445 times by 1 test
Evaluated by:
  • Self test
2-5445
514 {-
515 temp_var = set_if_not ("MAILCHECK", posixly_correct ? "600" : "60");-
516 VSETATTR (temp_var, att_integer);-
517 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
518-
519 /* Do some things with shell level. */-
520 initialize_shell_level ();-
521-
522 set_ppid ();-
523-
524 /* Initialize the `getopts' stuff. */-
525 temp_var = bind_variable ("OPTIND", "1", 0);-
526 VSETATTR (temp_var, att_integer);-
527 getopts_reset (0);-
528 bind_variable ("OPTERR", "1", 0);-
529 sh_opterr = 1;-
530-
531 if (login_shell == 1 && posixly_correct == 0)
login_shell == 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5446 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5446
532 set_home_var ();
executed 1 time by 1 test: set_home_var ();
Executed by:
  • Self test
1
533-
534 /* Get the full pathname to THIS shell, and set the BASH variable-
535 to it. */-
536 name = get_bash_name ();-
537 temp_var = bind_variable ("BASH", name, 0);-
538 free (name);-
539-
540 /* Make the exported environment variable SHELL be the user's login-
541 shell. Note that the `tset' command looks at this variable-
542 to determine what style of commands to output; if it ends in "csh",-
543 then C-shell commands are output, else Bourne shell commands. */-
544 set_shell_var ();-
545-
546 /* Make a variable called BASH_VERSION which contains the version info. */-
547 bind_variable ("BASH_VERSION", shell_version_string (), 0);-
548#if defined (ARRAY_VARS)-
549 make_vers_array ();-
550#endif-
551-
552 if (command_execution_string)
command_execution_stringDescription
TRUEevaluated 177 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5270 times by 1 test
Evaluated by:
  • Self test
177-5270
553 bind_variable ("BASH_EXECUTION_STRING", command_execution_string, 0);
executed 177 times by 1 test: bind_variable ("BASH_EXECUTION_STRING", command_execution_string, 0);
Executed by:
  • Self test
177
554-
555 /* Find out if we're supposed to be in Posix.2 mode via an-
556 environment variable. */-
557 temp_var = find_variable ("POSIXLY_CORRECT");-
558 if (!temp_var)
!temp_varDescription
TRUEevaluated 5430 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
17-5430
559 temp_var = find_variable ("POSIX_PEDANTIC");
executed 5430 times by 1 test: temp_var = find_variable ("POSIX_PEDANTIC");
Executed by:
  • Self test
5430
560 if (temp_var && imported_p (temp_var))
temp_varDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5430 times by 1 test
Evaluated by:
  • Self test
((((temp_var)-... (0x0008000)))Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-5430
561 sv_strict_posix (temp_var->name);
never executed: sv_strict_posix (temp_var->name);
0
562-
563#if defined (HISTORY)-
564 /* Set history variables to defaults, and then do whatever we would-
565 do if the variable had just been set. Do this only in the case-
566 that we are remembering commands on the history list. */-
567 if (remember_on_history)
remember_on_historyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5445 times by 1 test
Evaluated by:
  • Self test
2-5445
568 {-
569 name = bash_tilde_expand (posixly_correct ? "~/.sh_history" : "~/.bash_history", 0);-
570-
571 set_if_not ("HISTFILE", name);-
572 free (name);-
573 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
574#endif /* HISTORY */-
575-
576 /* Seed the random number generator. */-
577 seedrand ();-
578-
579 /* Handle some "special" variables that we may have inherited from a-
580 parent shell. */-
581 if (interactive_shell)
interactive_shellDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5445 times by 1 test
Evaluated by:
  • Self test
2-5445
582 {-
583 temp_var = find_variable ("IGNOREEOF");-
584 if (!temp_var)
!temp_varDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
585 temp_var = find_variable ("ignoreeof");
executed 2 times by 1 test: temp_var = find_variable ("ignoreeof");
Executed by:
  • Self test
2
586 if (temp_var && imported_p (temp_var))
temp_varDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
((((temp_var)-... (0x0008000)))Description
TRUEnever evaluated
FALSEnever evaluated
0-2
587 sv_ignoreeof (temp_var->name);
never executed: sv_ignoreeof (temp_var->name);
0
588 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
589-
590#if defined (HISTORY)-
591 if (interactive_shell && remember_on_history)
interactive_shellDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5445 times by 1 test
Evaluated by:
  • Self test
remember_on_historyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5445
592 {-
593 sv_history_control ("HISTCONTROL");-
594 sv_histignore ("HISTIGNORE");-
595 sv_histtimefmt ("HISTTIMEFORMAT");-
596 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
597#endif /* HISTORY */-
598-
599#if defined (READLINE) && defined (STRICT_POSIX)-
600 /* POSIXLY_CORRECT will be 1 here if the shell was compiled-
601 -DSTRICT_POSIX or if POSIXLY_CORRECT was supplied in the shell's-
602 environment */-
603 if (interactive_shell && posixly_correct && no_line_editing == 0)-
604 rl_prefer_env_winsize = 1;-
605#endif /* READLINE && STRICT_POSIX */-
606-
607 /*-
608 * 24 October 2001-
609 *-
610 * I'm tired of the arguing and bug reports. Bash now leaves SSH_CLIENT-
611 * and SSH2_CLIENT alone. I'm going to rely on the shell_level check in-
612 * isnetconn() to avoid running the startup files more often than wanted.-
613 * That will, of course, only work if the user's login shell is bash, so-
614 * I've made that behavior conditional on SSH_SOURCE_BASHRC being defined-
615 * in config-top.h.-
616 */-
617#if 0-
618 temp_var = find_variable ("SSH_CLIENT");-
619 if (temp_var && imported_p (temp_var))-
620 {-
621 VUNSETATTR (temp_var, att_exported);-
622 array_needs_making = 1;-
623 }-
624 temp_var = find_variable ("SSH2_CLIENT");-
625 if (temp_var && imported_p (temp_var))-
626 {-
627 VUNSETATTR (temp_var, att_exported);-
628 array_needs_making = 1;-
629 }-
630#endif-
631-
632 /* Get the user's real and effective user ids. */-
633 uidset ();-
634-
635 temp_var = find_variable ("BASH_XTRACEFD");-
636 if (temp_var && imported_p (temp_var))
temp_varDescription
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
((((temp_var)-... (0x0008000)))Description
TRUEnever evaluated
FALSEnever evaluated
0-5447
637 sv_xtracefd (temp_var->name);
never executed: sv_xtracefd (temp_var->name);
0
638-
639 sv_shcompat ("BASH_COMPAT");-
640-
641 /* Allow FUNCNEST to be inherited from the environment. */-
642 sv_funcnest ("FUNCNEST");-
643-
644 /* Initialize the dynamic variables, and seed their values. */-
645 initialize_dynamic_variables ();-
646}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
647-
648/* **************************************************************** */-
649/* */-
650/* Setting values for special shell variables */-
651/* */-
652/* **************************************************************** */-
653-
654static void-
655set_machine_vars ()-
656{-
657 SHELL_VAR *temp_var;-
658-
659 temp_var = set_if_not ("HOSTTYPE", HOSTTYPE);-
660 temp_var = set_if_not ("OSTYPE", OSTYPE);-
661 temp_var = set_if_not ("MACHTYPE", MACHTYPE);-
662-
663 temp_var = set_if_not ("HOSTNAME", current_host_name);-
664}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
665-
666/* Set $HOME to the information in the password file if we didn't get-
667 it from the environment. */-
668-
669/* This function is not static so the tilde and readline libraries can-
670 use it. */-
671char *-
672sh_get_home_dir ()-
673{-
674 if (current_user.home_dir == 0)
current_user.home_dir == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
675 get_current_user_info ();
never executed: get_current_user_info ();
0
676 return current_user.home_dir;
never executed: return current_user.home_dir;
0
677}-
678-
679static void-
680set_home_var ()-
681{-
682 SHELL_VAR *temp_var;-
683-
684 temp_var = find_variable ("HOME");-
685 if (temp_var == 0)
temp_var == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
686 temp_var = bind_variable ("HOME", sh_get_home_dir (), 0);
never executed: temp_var = bind_variable ("HOME", sh_get_home_dir (), 0);
0
687#if 0-
688 VSETATTR (temp_var, att_exported);-
689#endif-
690}
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
691-
692/* Set $SHELL to the user's login shell if it is not already set. Call-
693 get_current_user_info if we haven't already fetched the shell. */-
694static void-
695set_shell_var ()-
696{-
697 SHELL_VAR *temp_var;-
698-
699 temp_var = find_variable ("SHELL");-
700 if (temp_var == 0)
temp_var == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
3-5444
701 {-
702 if (current_user.shell == 0)
current_user.shell == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
703 get_current_user_info ();
executed 3 times by 1 test: get_current_user_info ();
Executed by:
  • Self test
3
704 temp_var = bind_variable ("SHELL", current_user.shell, 0);-
705 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
706#if 0-
707 VSETATTR (temp_var, att_exported);-
708#endif-
709}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
710-
711static char *-
712get_bash_name ()-
713{-
714 char *name;-
715-
716 if ((login_shell == 1) && RELPATH(shell_name))
(login_shell == 1)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5446 times by 1 test
Evaluated by:
  • Self test
((shell_name)[0] != '/')Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5446
717 {-
718 if (current_user.shell == 0)
current_user.shell == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
719 get_current_user_info ();
executed 1 time by 1 test: get_current_user_info ();
Executed by:
  • Self test
1
720 name = savestring (current_user.shell);-
721 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
722 else if (ABSPATH(shell_name))
((shell_name)[0] == '/')Description
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-5444
723 name = savestring (shell_name);
executed 5444 times by 1 test: name = (char *)strcpy (sh_xmalloc((1 + strlen (shell_name)), "variables.c", 723), (shell_name));
Executed by:
  • Self test
5444
724 else if (shell_name[0] == '.' && shell_name[1] == '/')
shell_name[0] == '.'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
shell_name[1] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
0-2
725 {-
726 /* Fast path for common case. */-
727 char *cdir;-
728 int len;-
729-
730 cdir = get_string_value ("PWD");-
731 if (cdir)
cdirDescription
TRUEnever evaluated
FALSEnever evaluated
0
732 {-
733 len = strlen (cdir);-
734 name = (char *)xmalloc (len + strlen (shell_name) + 1);-
735 strcpy (name, cdir);-
736 strcpy (name + len, shell_name + 1);-
737 }
never executed: end of block
0
738 else-
739 name = savestring (shell_name);
never executed: name = (char *)strcpy (sh_xmalloc((1 + strlen (shell_name)), "variables.c", 739), (shell_name));
0
740 }-
741 else-
742 {-
743 char *tname;-
744 int s;-
745-
746 tname = find_user_command (shell_name);-
747-
748 if (tname == 0)
tname == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
749 {-
750 /* Try the current directory. If there is not an executable-
751 there, just punt and use the login shell. */-
752 s = file_status (shell_name);-
753 if (s & FS_EXECABLE)
s & 0x2Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
754 {-
755 tname = make_absolute (shell_name, get_string_value ("PWD"));-
756 if (*shell_name == '.')
*shell_name == '.'Description
TRUEnever evaluated
FALSEnever evaluated
0
757 {-
758 name = sh_canonpath (tname, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);-
759 if (name == 0)
name == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
760 name = tname;
never executed: name = tname;
0
761 else-
762 free (tname);
never executed: sh_xfree((tname), "variables.c", 762);
0
763 }-
764 else-
765 name = tname;
never executed: name = tname;
0
766 }-
767 else-
768 {-
769 if (current_user.shell == 0)
current_user.shell == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
770 get_current_user_info ();
executed 2 times by 1 test: get_current_user_info ();
Executed by:
  • Self test
2
771 name = savestring (current_user.shell);-
772 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
773 }-
774 else-
775 {-
776 name = full_pathname (tname);-
777 free (tname);-
778 }
never executed: end of block
0
779 }-
780-
781 return (name);
executed 5447 times by 1 test: return (name);
Executed by:
  • Self test
5447
782}-
783-
784void-
785adjust_shell_level (change)-
786 int change;-
787{-
788 char new_level[5], *old_SHLVL;-
789 intmax_t old_level;-
790 SHELL_VAR *temp_var;-
791-
792 old_SHLVL = get_string_value ("SHLVL");-
793 if (old_SHLVL == 0 || *old_SHLVL == '\0' || legal_number (old_SHLVL, &old_level) == 0)
old_SHLVL == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5448 times by 1 test
Evaluated by:
  • Self test
*old_SHLVL == '\0'Description
TRUEnever evaluated
FALSEevaluated 5448 times by 1 test
Evaluated by:
  • Self test
legal_number (...ld_level) == 0Description
TRUEnever evaluated
FALSEevaluated 5448 times by 1 test
Evaluated by:
  • Self test
0-5448
794 old_level = 0;
executed 3 times by 1 test: old_level = 0;
Executed by:
  • Self test
3
795-
796 shell_level = old_level + change;-
797 if (shell_level < 0)
shell_level < 0Description
TRUEnever evaluated
FALSEevaluated 5451 times by 1 test
Evaluated by:
  • Self test
0-5451
798 shell_level = 0;
never executed: shell_level = 0;
0
799 else if (shell_level >= 1000)
shell_level >= 1000Description
TRUEnever evaluated
FALSEevaluated 5451 times by 1 test
Evaluated by:
  • Self test
0-5451
800 {-
801 internal_warning (_("shell level (%d) too high, resetting to 1"), shell_level);-
802 shell_level = 1;-
803 }
never executed: end of block
0
804-
805 /* We don't need the full generality of itos here. */-
806 if (shell_level < 10)
shell_level < 10Description
TRUEevaluated 5451 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5451
807 {-
808 new_level[0] = shell_level + '0';-
809 new_level[1] = '\0';-
810 }
executed 5451 times by 1 test: end of block
Executed by:
  • Self test
5451
811 else if (shell_level < 100)
shell_level < 100Description
TRUEnever evaluated
FALSEnever evaluated
0
812 {-
813 new_level[0] = (shell_level / 10) + '0';-
814 new_level[1] = (shell_level % 10) + '0';-
815 new_level[2] = '\0';-
816 }
never executed: end of block
0
817 else if (shell_level < 1000)
shell_level < 1000Description
TRUEnever evaluated
FALSEnever evaluated
0
818 {-
819 new_level[0] = (shell_level / 100) + '0';-
820 old_level = shell_level % 100;-
821 new_level[1] = (old_level / 10) + '0';-
822 new_level[2] = (old_level % 10) + '0';-
823 new_level[3] = '\0';-
824 }
never executed: end of block
0
825-
826 temp_var = bind_variable ("SHLVL", new_level, 0);-
827 set_auto_export (temp_var);-
828}
executed 5451 times by 1 test: end of block
Executed by:
  • Self test
5451
829-
830static void-
831initialize_shell_level ()-
832{-
833 adjust_shell_level (1);-
834}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
835-
836/* If we got PWD from the environment, update our idea of the current-
837 working directory. In any case, make sure that PWD exists before-
838 checking it. It is possible for getcwd () to fail on shell startup,-
839 and in that case, PWD would be undefined. If this is an interactive-
840 login shell, see if $HOME is the current working directory, and if-
841 that's not the same string as $PWD, set PWD=$HOME. */-
842-
843void-
844set_pwd ()-
845{-
846 SHELL_VAR *temp_var, *home_var;-
847 char *temp_string, *home_string, *current_dir;-
848-
849 home_var = find_variable ("HOME");-
850 home_string = home_var ? value_cell (home_var) : (char *)NULL;
home_varDescription
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-5444
851-
852 temp_var = find_variable ("PWD");-
853 /* Follow posix rules for importing PWD */-
854 if (temp_var && imported_p (temp_var) &&
temp_varDescription
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
((((temp_var)-... (0x0008000)))Description
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5444
855 (temp_string = value_cell (temp_var)) &&
(temp_string =..._var)->value))Description
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5444
856 temp_string[0] == '/' &&
temp_string[0] == '/'Description
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5444
857 same_file (temp_string, ".", (struct stat *)NULL, (struct stat *)NULL))
same_file (tem... ((void *)0) )Description
TRUEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5444
858 {-
859 current_dir = sh_canonpath (temp_string, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);-
860 if (current_dir == 0)
current_dir == 0Description
TRUEnever evaluated
FALSEevaluated 5444 times by 1 test
Evaluated by:
  • Self test
0-5444
861 current_dir = get_working_directory ("shell_init");
never executed: current_dir = get_working_directory ("shell_init");
0
862 else-
863 set_working_directory (current_dir);
executed 5444 times by 1 test: set_working_directory (current_dir);
Executed by:
  • Self test
5444
864 if (posixly_correct && current_dir)
posixly_correctDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5427 times by 1 test
Evaluated by:
  • Self test
current_dirDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5427
865 {-
866 temp_var = bind_variable ("PWD", current_dir, 0);-
867 set_auto_export (temp_var);-
868 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
869 free (current_dir);-
870 }
executed 5444 times by 1 test: end of block
Executed by:
  • Self test
5444
871 else if (home_string && interactive_shell && login_shell &&
home_stringDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
interactive_shellDescription
TRUEnever evaluated
FALSEnever evaluated
login_shellDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
872 same_file (home_string, ".", (struct stat *)NULL, (struct stat *)NULL))
same_file (hom... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
873 {-
874 set_working_directory (home_string);-
875 temp_var = bind_variable ("PWD", home_string, 0);-
876 set_auto_export (temp_var);-
877 }
never executed: end of block
0
878 else-
879 {-
880 temp_string = get_working_directory ("shell-init");-
881 if (temp_string)
temp_stringDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
882 {-
883 temp_var = bind_variable ("PWD", temp_string, 0);-
884 set_auto_export (temp_var);-
885 free (temp_string);-
886 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
887 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
888-
889 /* According to the Single Unix Specification, v2, $OLDPWD is an-
890 `environment variable' and therefore should be auto-exported. If we-
891 don't find OLDPWD in the environment, or it doesn't name a directory,-
892 make a dummy invisible variable for OLDPWD, and mark it as exported. */-
893 temp_var = find_variable ("OLDPWD");-
894#if defined (OLDPWD_CHECK_DIRECTORY)-
895 if (temp_var == 0 || value_cell (temp_var) == 0 || file_isdir (value_cell (temp_var)) == 0)
temp_var == 0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5421 times by 1 test
Evaluated by:
  • Self test
((temp_var)->value) == 0Description
TRUEnever evaluated
FALSEevaluated 5421 times by 1 test
Evaluated by:
  • Self test
file_isdir (((...->value)) == 0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5398 times by 1 test
Evaluated by:
  • Self test
0-5421
896#else-
897 if (temp_var == 0 || value_cell (temp_var) == 0)-
898#endif-
899 {-
900 temp_var = bind_variable ("OLDPWD", (char *)NULL, 0);-
901 VSETATTR (temp_var, (att_exported | att_invisible));-
902 }
executed 49 times by 1 test: end of block
Executed by:
  • Self test
49
903}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
904-
905/* Make a variable $PPID, which holds the pid of the shell's parent. */-
906void-
907set_ppid ()-
908{-
909 char namebuf[INT_STRLEN_BOUND(pid_t) + 1], *name;-
910 SHELL_VAR *temp_var;-
911-
912 name = inttostr (getppid (), namebuf, sizeof(namebuf));-
913 temp_var = find_variable ("PPID");-
914 if (temp_var)
temp_varDescription
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
915 VUNSETATTR (temp_var, (att_readonly | att_exported));
never executed: ((temp_var)->attributes &= ~((0x0000002 | 0x0000001)));
0
916 temp_var = bind_variable ("PPID", name, 0);-
917 VSETATTR (temp_var, (att_readonly | att_integer));-
918}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
919-
920static void-
921uidset ()-
922{-
923 char buff[INT_STRLEN_BOUND(uid_t) + 1], *b;-
924 register SHELL_VAR *v;-
925-
926 b = inttostr (current_user.uid, buff, sizeof (buff));-
927 v = find_variable ("UID");-
928 if (v == 0)
v == 0Description
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5447
929 {-
930 v = bind_variable ("UID", b, 0);-
931 VSETATTR (v, (att_readonly | att_integer));-
932 }
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
933-
934 if (current_user.euid != current_user.uid)
current_user.e...rrent_user.uidDescription
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
935 b = inttostr (current_user.euid, buff, sizeof (buff));
never executed: b = inttostr (current_user.euid, buff, sizeof (buff));
0
936-
937 v = find_variable ("EUID");-
938 if (v == 0)
v == 0Description
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5447
939 {-
940 v = bind_variable ("EUID", b, 0);-
941 VSETATTR (v, (att_readonly | att_integer));-
942 }
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
943}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
944-
945#if defined (ARRAY_VARS)-
946static void-
947make_vers_array ()-
948{-
949 SHELL_VAR *vv;-
950 ARRAY *av;-
951 char *s, d[32], b[INT_STRLEN_BOUND(int) + 1];-
952-
953 unbind_variable_noref ("BASH_VERSINFO");-
954-
955 vv = make_new_array_variable ("BASH_VERSINFO");-
956 av = array_cell (vv);-
957 strcpy (d, dist_version);-
958 s = strchr (d, '.');
__builtin_constant_p ( '.' )Description
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!__builtin_constant_p ( d )Description
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
959 if (s)
sDescription
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5447
960 *s++ = '\0';
executed 5447 times by 1 test: *s++ = '\0';
Executed by:
  • Self test
5447
961 array_insert (av, 0, d);-
962 array_insert (av, 1, s);-
963 s = inttostr (patch_level, b, sizeof (b));-
964 array_insert (av, 2, s);-
965 s = inttostr (build_version, b, sizeof (b));-
966 array_insert (av, 3, s);-
967 array_insert (av, 4, release_status);-
968 array_insert (av, 5, MACHTYPE);-
969-
970 VSETATTR (vv, att_readonly);-
971}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
972#endif /* ARRAY_VARS */-
973-
974/* Set the environment variables $LINES and $COLUMNS in response to-
975 a window size change. */-
976void-
977sh_set_lines_and_columns (lines, cols)-
978 int lines, cols;-
979{-
980 char val[INT_STRLEN_BOUND(int) + 1], *v;-
981-
982#if defined (READLINE)-
983 /* If we are currently assigning to LINES or COLUMNS, don't do anything. */-
984 if (winsize_assignment)
winsize_assignmentDescription
TRUEnever evaluated
FALSEnever evaluated
0
985 return;
never executed: return;
0
986#endif-
987-
988 v = inttostr (lines, val, sizeof (val));-
989 bind_variable ("LINES", v, 0);-
990-
991 v = inttostr (cols, val, sizeof (val));-
992 bind_variable ("COLUMNS", v, 0);-
993}
never executed: end of block
0
994-
995/* **************************************************************** */-
996/* */-
997/* Printing variables and values */-
998/* */-
999/* **************************************************************** */-
1000-
1001/* Print LIST (a list of shell variables) to stdout in such a way that-
1002 they can be read back in. */-
1003void-
1004print_var_list (list)-
1005 register SHELL_VAR **list;-
1006{-
1007 register int i;-
1008 register SHELL_VAR *var;-
1009-
1010 for (i = 0; list && (var = list[i]); i++)
listDescription
TRUEevaluated 429 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(var = list[i])Description
TRUEevaluated 423 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-429
1011 if (invisible_p (var) == 0)
((((var)->attr...001000))) == 0Description
TRUEevaluated 417 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-417
1012 print_assignment (var);
executed 417 times by 1 test: print_assignment (var);
Executed by:
  • Self test
417
1013}
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
1014-
1015/* Print LIST (a list of shell functions) to stdout in such a way that-
1016 they can be read back in. */-
1017void-
1018print_func_list (list)-
1019 register SHELL_VAR **list;-
1020{-
1021 register int i;-
1022 register SHELL_VAR *var;-
1023-
1024 for (i = 0; list && (var = list[i]); i++)
listDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(var = list[i])Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-12
1025 {-
1026 printf ("%s ", var->name);-
1027 print_var_function (var);-
1028 printf ("\n");-
1029 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
1030}
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
1031 -
1032/* Print the value of a single SHELL_VAR. No newline is-
1033 output, but the variable is printed in such a way that-
1034 it can be read back in. */-
1035void-
1036print_assignment (var)-
1037 SHELL_VAR *var;-
1038{-
1039 if (var_isset (var) == 0)
((var)->value != 0) == 0Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 357 times by 1 test
Evaluated by:
  • Self test
66-357
1040 return;
executed 66 times by 1 test: return;
Executed by:
  • Self test
66
1041-
1042 if (function_p (var))
((((var)->attr... (0x0000008)))Description
TRUEnever evaluated
FALSEevaluated 357 times by 1 test
Evaluated by:
  • Self test
0-357
1043 {-
1044 printf ("%s", var->name);-
1045 print_var_function (var);-
1046 printf ("\n");-
1047 }
never executed: end of block
0
1048#if defined (ARRAY_VARS)-
1049 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 306 times by 1 test
Evaluated by:
  • Self test
51-306
1050 print_array_assignment (var, 0);
executed 51 times by 1 test: print_array_assignment (var, 0);
Executed by:
  • Self test
51
1051 else if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 292 times by 1 test
Evaluated by:
  • Self test
14-292
1052 print_assoc_assignment (var, 0);
executed 14 times by 1 test: print_assoc_assignment (var, 0);
Executed by:
  • Self test
14
1053#endif /* ARRAY_VARS */-
1054 else-
1055 {-
1056 printf ("%s=", var->name);-
1057 print_var_value (var, 1);-
1058 printf ("\n");-
1059 }
executed 292 times by 1 test: end of block
Executed by:
  • Self test
292
1060}-
1061-
1062/* Print the value cell of VAR, a shell variable. Do not print-
1063 the name, nor leading/trailing newline. If QUOTE is non-zero,-
1064 and the value contains shell metacharacters, quote the value-
1065 in such a way that it can be read back in. */-
1066void-
1067print_var_value (var, quote)-
1068 SHELL_VAR *var;-
1069 int quote;-
1070{-
1071 char *t;-
1072-
1073 if (var_isset (var) == 0)
((var)->value != 0) == 0Description
TRUEnever evaluated
FALSEevaluated 292 times by 1 test
Evaluated by:
  • Self test
0-292
1074 return;
never executed: return;
0
1075-
1076 if (quote && posixly_correct == 0 && ansic_shouldquote (value_cell (var)))
quoteDescription
TRUEevaluated 292 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correct == 0Description
TRUEevaluated 292 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ansic_shouldqu...(var)->value))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 282 times by 1 test
Evaluated by:
  • Self test
0-292
1077 {-
1078 t = ansic_quote (value_cell (var), 0, (int *)0);-
1079 printf ("%s", t);-
1080 free (t);-
1081 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test
10
1082 else if (quote && sh_contains_shell_metas (value_cell (var)))
quoteDescription
TRUEevaluated 282 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
sh_contains_sh...(var)->value))Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 258 times by 1 test
Evaluated by:
  • Self test
0-282
1083 {-
1084 t = sh_single_quote (value_cell (var));-
1085 printf ("%s", t);-
1086 free (t);-
1087 }
executed 24 times by 1 test: end of block
Executed by:
  • Self test
24
1088 else-
1089 printf ("%s", value_cell (var));
executed 258 times by 1 test: printf ("%s", ((var)->value));
Executed by:
  • Self test
258
1090}-
1091-
1092/* Print the function cell of VAR, a shell variable. Do not-
1093 print the name, nor leading/trailing newline. */-
1094void-
1095print_var_function (var)-
1096 SHELL_VAR *var;-
1097{-
1098 char *x;-
1099-
1100 if (function_p (var) && var_isset (var))
((((var)->attr... (0x0000008)))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((var)->value != 0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
1101 {-
1102 x = named_function_string ((char *)NULL, function_cell(var), FUNC_MULTILINE|FUNC_EXTERNAL);-
1103 printf ("%s", x);-
1104 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
1105}
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
1106-
1107/* **************************************************************** */-
1108/* */-
1109/* Dynamic Variables */-
1110/* */-
1111/* **************************************************************** */-
1112-
1113/* DYNAMIC VARIABLES-
1114-
1115 These are variables whose values are generated anew each time they are-
1116 referenced. These are implemented using a pair of function pointers-
1117 in the struct variable: assign_func, which is called from bind_variable-
1118 and, if arrays are compiled into the shell, some of the functions in-
1119 arrayfunc.c, and dynamic_value, which is called from find_variable.-
1120-
1121 assign_func is called from bind_variable_internal, if-
1122 bind_variable_internal discovers that the variable being assigned to-
1123 has such a function. The function is called as-
1124 SHELL_VAR *temp = (*(entry->assign_func)) (entry, value, ind)-
1125 and the (SHELL_VAR *)temp is returned as the value of bind_variable. It-
1126 is usually ENTRY (self). IND is an index for an array variable, and-
1127 unused otherwise.-
1128-
1129 dynamic_value is called from find_variable_internal to return a `new'-
1130 value for the specified dynamic varible. If this function is NULL,-
1131 the variable is treated as a `normal' shell variable. If it is not,-
1132 however, then this function is called like this:-
1133 tempvar = (*(var->dynamic_value)) (var);-
1134-
1135 Sometimes `tempvar' will replace the value of `var'. Other times, the-
1136 shell will simply use the string value. Pretty object-oriented, huh?-
1137-
1138 Be warned, though: if you `unset' a special variable, it loses its-
1139 special meaning, even if you subsequently set it.-
1140-
1141 The special assignment code would probably have been better put in-
1142 subst.c: do_assignment_internal, in the same style as-
1143 stupidly_hack_special_variables, but I wanted the changes as-
1144 localized as possible. */-
1145-
1146#define INIT_DYNAMIC_VAR(var, val, gfunc, afunc) \-
1147 do \-
1148 { \-
1149 v = bind_variable (var, (val), 0); \-
1150 v->dynamic_value = gfunc; \-
1151 v->assign_func = afunc; \-
1152 } \-
1153 while (0)-
1154-
1155#define INIT_DYNAMIC_ARRAY_VAR(var, gfunc, afunc) \-
1156 do \-
1157 { \-
1158 v = make_new_array_variable (var); \-
1159 v->dynamic_value = gfunc; \-
1160 v->assign_func = afunc; \-
1161 } \-
1162 while (0)-
1163-
1164#define INIT_DYNAMIC_ASSOC_VAR(var, gfunc, afunc) \-
1165 do \-
1166 { \-
1167 v = make_new_assoc_variable (var); \-
1168 v->dynamic_value = gfunc; \-
1169 v->assign_func = afunc; \-
1170 } \-
1171 while (0)-
1172-
1173static SHELL_VAR *-
1174null_assign (self, value, unused, key)-
1175 SHELL_VAR *self;-
1176 char *value;-
1177 arrayind_t unused;-
1178 char *key;-
1179{-
1180 return (self);
never executed: return (self);
0
1181}-
1182-
1183#if defined (ARRAY_VARS)-
1184static SHELL_VAR *-
1185null_array_assign (self, value, ind, key)-
1186 SHELL_VAR *self;-
1187 char *value;-
1188 arrayind_t ind;-
1189 char *key;-
1190{-
1191 return (self);
executed 4 times by 1 test: return (self);
Executed by:
  • Self test
4
1192}-
1193#endif-
1194-
1195/* Degenerate `dynamic_value' function; just returns what's passed without-
1196 manipulation. */-
1197static SHELL_VAR *-
1198get_self (self)-
1199 SHELL_VAR *self;-
1200{-
1201 return (self);
executed 3319909 times by 1 test: return (self);
Executed by:
  • Self test
3319909
1202}-
1203-
1204#if defined (ARRAY_VARS)-
1205/* A generic dynamic array variable initializer. Initialize array variable-
1206 NAME with dynamic value function GETFUNC and assignment function SETFUNC. */-
1207static SHELL_VAR *-
1208init_dynamic_array_var (name, getfunc, setfunc, attrs)-
1209 char *name;-
1210 sh_var_value_func_t *getfunc;-
1211 sh_var_assign_func_t *setfunc;-
1212 int attrs;-
1213{-
1214 SHELL_VAR *v;-
1215-
1216 v = find_variable (name);-
1217 if (v)
vDescription
TRUEnever evaluated
FALSEevaluated 32682 times by 1 test
Evaluated by:
  • Self test
0-32682
1218 return (v);
never executed: return (v);
0
1219 INIT_DYNAMIC_ARRAY_VAR (name, getfunc, setfunc);-
1220 if (attrs)
attrsDescription
TRUEevaluated 27235 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
5447-27235
1221 VSETATTR (v, attrs);
executed 27235 times by 1 test: ((v)->attributes |= (attrs));
Executed by:
  • Self test
27235
1222 return v;
executed 32682 times by 1 test: return v;
Executed by:
  • Self test
32682
1223}-
1224-
1225static SHELL_VAR *-
1226init_dynamic_assoc_var (name, getfunc, setfunc, attrs)-
1227 char *name;-
1228 sh_var_value_func_t *getfunc;-
1229 sh_var_assign_func_t *setfunc;-
1230 int attrs;-
1231{-
1232 SHELL_VAR *v;-
1233-
1234 v = find_variable (name);-
1235 if (v)
vDescription
TRUEnever evaluated
FALSEevaluated 10894 times by 1 test
Evaluated by:
  • Self test
0-10894
1236 return (v);
never executed: return (v);
0
1237 INIT_DYNAMIC_ASSOC_VAR (name, getfunc, setfunc);-
1238 if (attrs)
attrsDescription
TRUEevaluated 10894 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10894
1239 VSETATTR (v, attrs);
executed 10894 times by 1 test: ((v)->attributes |= (attrs));
Executed by:
  • Self test
10894
1240 return v;
executed 10894 times by 1 test: return v;
Executed by:
  • Self test
10894
1241}-
1242#endif-
1243-
1244/* The value of $SECONDS. This is the number of seconds since shell-
1245 invocation, or, the number of seconds since the last assignment + the-
1246 value of the last assignment. */-
1247static intmax_t seconds_value_assigned;-
1248-
1249static SHELL_VAR *-
1250assign_seconds (self, value, unused, key)-
1251 SHELL_VAR *self;-
1252 char *value;-
1253 arrayind_t unused;-
1254 char *key;-
1255{-
1256 if (legal_number (value, &seconds_value_assigned) == 0)
legal_number (...assigned) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1257 seconds_value_assigned = 0;
never executed: seconds_value_assigned = 0;
0
1258 shell_start_time = NOW;-
1259 return (self);
never executed: return (self);
0
1260}-
1261-
1262static SHELL_VAR *-
1263get_seconds (var)-
1264 SHELL_VAR *var;-
1265{-
1266 time_t time_since_start;-
1267 char *p;-
1268-
1269 time_since_start = NOW - shell_start_time;-
1270 p = itos(seconds_value_assigned + time_since_start);-
1271-
1272 FREE (value_cell (var));
executed 1 time by 1 test: sh_xfree((((var)->value)), "variables.c", 1272);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1
1273-
1274 VSETATTR (var, att_integer);-
1275 var_setvalue (var, p);-
1276 return (var);
executed 2 times by 1 test: return (var);
Executed by:
  • Self test
2
1277}-
1278-
1279static SHELL_VAR *-
1280init_seconds_var ()-
1281{-
1282 SHELL_VAR *v;-
1283-
1284 v = find_variable ("SECONDS");-
1285 if (v)
vDescription
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
1286 {-
1287 if (legal_number (value_cell(v), &seconds_value_assigned) == 0)
legal_number (...assigned) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1288 seconds_value_assigned = 0;
never executed: seconds_value_assigned = 0;
0
1289 }
never executed: end of block
0
1290 INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds);-
1291 return v;
executed 5447 times by 1 test: return v;
Executed by:
  • Self test
5447
1292}-
1293 -
1294/* The random number seed. You can change this by setting RANDOM. */-
1295static unsigned long rseed = 1;-
1296static int last_random_value;-
1297static int seeded_subshell = 0;-
1298-
1299/* A linear congruential random number generator based on the example-
1300 one in the ANSI C standard. This one isn't very good, but a more-
1301 complicated one is overkill. */-
1302-
1303/* Returns a pseudo-random number between 0 and 32767. */-
1304static int-
1305brand ()-
1306{-
1307 /* From "Random number generators: good ones are hard to find",-
1308 Park and Miller, Communications of the ACM, vol. 31, no. 10,-
1309 October 1988, p. 1195. filtered through FreeBSD */-
1310 long h, l;-
1311-
1312 /* Can't seed with 0. */-
1313 if (rseed == 0)
rseed == 0Description
TRUEnever evaluated
FALSEevaluated 20021 times by 1 test
Evaluated by:
  • Self test
0-20021
1314 rseed = 123459876;
never executed: rseed = 123459876;
0
1315 h = rseed / 127773;-
1316 l = rseed % 127773;-
1317 rseed = 16807 * l - 2836 * h;-
1318#if 0-
1319 if (rseed < 0)-
1320 rseed += 0x7fffffff;-
1321#endif-
1322 return ((unsigned int)(rseed & 32767)); /* was % 32768 */
executed 20021 times by 1 test: return ((unsigned int)(rseed & 32767));
Executed by:
  • Self test
20021
1323}-
1324-
1325/* Set the random number generator seed to SEED. */-
1326static void-
1327sbrand (seed)-
1328 unsigned long seed;-
1329{-
1330 rseed = seed;-
1331 last_random_value = 0;-
1332}
executed 5452 times by 1 test: end of block
Executed by:
  • Self test
5452
1333-
1334static void-
1335seedrand ()-
1336{-
1337 struct timeval tv;-
1338-
1339 gettimeofday (&tv, NULL);-
1340 sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());-
1341}
executed 5448 times by 1 test: end of block
Executed by:
  • Self test
5448
1342-
1343static SHELL_VAR *-
1344assign_random (self, value, unused, key)-
1345 SHELL_VAR *self;-
1346 char *value;-
1347 arrayind_t unused;-
1348 char *key;-
1349{-
1350 sbrand (strtoul (value, (char **)NULL, 10));-
1351 if (subshell_environment)
subshell_environmentDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-4
1352 seeded_subshell = getpid ();
never executed: seeded_subshell = getpid ();
0
1353 return (self);
executed 4 times by 1 test: return (self);
Executed by:
  • Self test
4
1354}-
1355-
1356int-
1357get_random_number ()-
1358{-
1359 int rv, pid;-
1360-
1361 /* Reset for command and process substitution. */-
1362 pid = getpid ();-
1363 if (subshell_environment && seeded_subshell != pid)
subshell_environmentDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20020 times by 1 test
Evaluated by:
  • Self test
seeded_subshell != pidDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-20020
1364 {-
1365 seedrand ();-
1366 seeded_subshell = pid;-
1367 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
1368-
1369 do-
1370 rv = brand ();
executed 20021 times by 1 test: rv = brand ();
Executed by:
  • Self test
20021
1371 while (rv == last_random_value);
rv == last_random_valueDescription
TRUEnever evaluated
FALSEevaluated 20021 times by 1 test
Evaluated by:
  • Self test
0-20021
1372 return rv;
executed 20021 times by 1 test: return rv;
Executed by:
  • Self test
20021
1373}-
1374-
1375static SHELL_VAR *-
1376get_random (var)-
1377 SHELL_VAR *var;-
1378{-
1379 int rv;-
1380 char *p;-
1381-
1382 rv = get_random_number ();-
1383 last_random_value = rv;-
1384 p = itos (rv);-
1385-
1386 FREE (value_cell (var));
executed 20012 times by 1 test: sh_xfree((((var)->value)), "variables.c", 1386);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 20012 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-20012
1387-
1388 VSETATTR (var, att_integer);-
1389 var_setvalue (var, p);-
1390 return (var);
executed 20021 times by 1 test: return (var);
Executed by:
  • Self test
20021
1391}-
1392-
1393static SHELL_VAR *-
1394assign_lineno (var, value, unused, key)-
1395 SHELL_VAR *var;-
1396 char *value;-
1397 arrayind_t unused;-
1398 char *key;-
1399{-
1400 intmax_t new_value;-
1401-
1402 if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
value == 0Description
TRUEnever evaluated
FALSEnever evaluated
*value == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
legal_number (...ew_value) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1403 new_value = 0;
never executed: new_value = 0;
0
1404 line_number = line_number_base = new_value;-
1405 return var;
never executed: return var;
0
1406}-
1407-
1408/* Function which returns the current line number. */-
1409static SHELL_VAR *-
1410get_lineno (var)-
1411 SHELL_VAR *var;-
1412{-
1413 char *p;-
1414 int ln;-
1415-
1416 ln = executing_line_number ();-
1417 p = itos (ln);-
1418 FREE (value_cell (var));
executed 2243 times by 1 test: sh_xfree((((var)->value)), "variables.c", 1418);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 2243 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
31-2243
1419 var_setvalue (var, p);-
1420 return (var);
executed 2274 times by 1 test: return (var);
Executed by:
  • Self test
2274
1421}-
1422-
1423static SHELL_VAR *-
1424assign_subshell (var, value, unused, key)-
1425 SHELL_VAR *var;-
1426 char *value;-
1427 arrayind_t unused;-
1428 char *key;-
1429{-
1430 intmax_t new_value;-
1431-
1432 if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
value == 0Description
TRUEnever evaluated
FALSEnever evaluated
*value == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
legal_number (...ew_value) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1433 new_value = 0;
never executed: new_value = 0;
0
1434 subshell_level = new_value;-
1435 return var;
never executed: return var;
0
1436}-
1437-
1438static SHELL_VAR *-
1439get_subshell (var)-
1440 SHELL_VAR *var;-
1441{-
1442 char *p;-
1443-
1444 p = itos (subshell_level);-
1445 FREE (value_cell (var));
executed 1 time by 1 test: sh_xfree((((var)->value)), "variables.c", 1445);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
1-4
1446 var_setvalue (var, p);-
1447 return (var);
executed 5 times by 1 test: return (var);
Executed by:
  • Self test
5
1448}-
1449-
1450static SHELL_VAR *-
1451get_epochseconds (var)-
1452 SHELL_VAR *var;-
1453{-
1454 intmax_t now;-
1455 char *p;-
1456-
1457 now = NOW;-
1458 p = itos (now);-
1459-
1460 FREE (value_cell (var));
never executed: sh_xfree((((var)->value)), "variables.c", 1460);
((var)->value)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
1461 var_setvalue (var, p);-
1462 return (var);
executed 1 time by 1 test: return (var);
Executed by:
  • Self test
1
1463}-
1464-
1465static SHELL_VAR *-
1466get_epochrealtime (var)-
1467 SHELL_VAR *var;-
1468{-
1469 char buf[32];-
1470 char *p;-
1471 struct timeval tv;-
1472-
1473 gettimeofday (&tv, NULL);-
1474 snprintf (buf, sizeof (buf), "%u%c%06u", (unsigned)tv.tv_sec,-
1475 locale_decpoint (),-
1476 (unsigned)tv.tv_usec);-
1477-
1478 p = savestring (buf);-
1479 FREE (value_cell (var));
executed 1 time by 1 test: sh_xfree((((var)->value)), "variables.c", 1479);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1
1480 var_setvalue (var, p);-
1481 return (var);
executed 2 times by 1 test: return (var);
Executed by:
  • Self test
2
1482}-
1483-
1484static SHELL_VAR *-
1485get_bashpid (var)-
1486 SHELL_VAR *var;-
1487{-
1488 int pid;-
1489 char *p;-
1490-
1491 pid = getpid ();-
1492 p = itos (pid);-
1493-
1494 FREE (value_cell (var));
executed 1 time by 1 test: sh_xfree((((var)->value)), "variables.c", 1494);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
1-8
1495 VSETATTR (var, att_integer); /* XXX - was also att_readonly */-
1496 var_setvalue (var, p);-
1497 return (var);
executed 9 times by 1 test: return (var);
Executed by:
  • Self test
9
1498}-
1499-
1500static SHELL_VAR *-
1501get_bash_argv0 (var)-
1502 SHELL_VAR *var;-
1503{-
1504 char *p;-
1505-
1506 p = savestring (dollar_vars[0]);-
1507 FREE (value_cell (var));
never executed: sh_xfree((((var)->value)), "variables.c", 1507);
((var)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
1508 var_setvalue (var, p);-
1509 return var;
never executed: return var;
0
1510}-
1511-
1512static char *static_shell_name = 0;-
1513-
1514static SHELL_VAR *-
1515assign_bash_argv0 (var, value, unused, key)-
1516 SHELL_VAR *var;-
1517 char *value;-
1518 arrayind_t unused;-
1519 char *key;-
1520{-
1521 size_t vlen;-
1522-
1523 if (value == 0)
value == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1524 return var;
never executed: return var;
0
1525-
1526 FREE (dollar_vars[0]);
executed 2 times by 1 test: sh_xfree((dollar_vars[0]), "variables.c", 1526);
Executed by:
  • Self test
dollar_vars[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
1527 dollar_vars[0] = savestring (value);-
1528-
1529 /* Need these gyrations because shell_name isn't dynamically allocated */-
1530 vlen = STRLEN (value);
(value)[1]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[2]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
1531 static_shell_name = xrealloc (static_shell_name, vlen + 1);-
1532 strcpy (static_shell_name, value);-
1533 -
1534 shell_name = static_shell_name;-
1535 return var;
executed 2 times by 1 test: return var;
Executed by:
  • Self test
2
1536}-
1537 -
1538static SHELL_VAR *-
1539get_bash_command (var)-
1540 SHELL_VAR *var;-
1541{-
1542 char *p;-
1543-
1544 if (the_printed_command_except_trap)
the_printed_co...nd_except_trapDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
1545 p = savestring (the_printed_command_except_trap);
executed 1 time by 1 test: p = (char *)strcpy (sh_xmalloc((1 + strlen (the_printed_command_except_trap)), "variables.c", 1545), (the_printed_command_except_trap));
Executed by:
  • Self test
1
1546 else-
1547 {-
1548 p = (char *)xmalloc (1);-
1549 p[0] = '\0';-
1550 }
never executed: end of block
0
1551 FREE (value_cell (var));
never executed: sh_xfree((((var)->value)), "variables.c", 1551);
((var)->value)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
1552 var_setvalue (var, p);-
1553 return (var);
executed 1 time by 1 test: return (var);
Executed by:
  • Self test
1
1554}-
1555-
1556#if defined (HISTORY)-
1557static SHELL_VAR *-
1558get_histcmd (var)-
1559 SHELL_VAR *var;-
1560{-
1561 char *p;-
1562-
1563 p = itos (history_number ());-
1564 FREE (value_cell (var));
never executed: sh_xfree((((var)->value)), "variables.c", 1564);
((var)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
1565 var_setvalue (var, p);-
1566 return (var);
never executed: return (var);
0
1567}-
1568#endif-
1569-
1570#if defined (READLINE)-
1571/* When this function returns, VAR->value points to malloced memory. */-
1572static SHELL_VAR *-
1573get_comp_wordbreaks (var)-
1574 SHELL_VAR *var;-
1575{-
1576 /* If we don't have anything yet, assign a default value. */-
1577 if (rl_completer_word_break_characters == 0 && bash_readline_initialized == 0)
rl_completer_w...haracters == 0Description
TRUEnever evaluated
FALSEnever evaluated
bash_readline_initialized == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1578 enable_hostname_completion (perform_hostname_completion);
never executed: enable_hostname_completion (perform_hostname_completion);
0
1579-
1580 FREE (value_cell (var));
never executed: sh_xfree((((var)->value)), "variables.c", 1580);
((var)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
1581 var_setvalue (var, savestring (rl_completer_word_break_characters));-
1582-
1583 return (var);
never executed: return (var);
0
1584}-
1585-
1586/* When this function returns, rl_completer_word_break_characters points to-
1587 malloced memory. */-
1588static SHELL_VAR *-
1589assign_comp_wordbreaks (self, value, unused, key)-
1590 SHELL_VAR *self;-
1591 char *value;-
1592 arrayind_t unused;-
1593 char *key;-
1594{-
1595 if (rl_completer_word_break_characters &&
rl_completer_w...eak_charactersDescription
TRUEnever evaluated
FALSEnever evaluated
0
1596 rl_completer_word_break_characters != rl_basic_word_break_characters)
rl_completer_w...eak_charactersDescription
TRUEnever evaluated
FALSEnever evaluated
0
1597 free (rl_completer_word_break_characters);
never executed: sh_xfree((rl_completer_word_break_characters), "variables.c", 1597);
0
1598-
1599 rl_completer_word_break_characters = savestring (value);-
1600 return self;
never executed: return self;
0
1601}-
1602#endif /* READLINE */-
1603-
1604#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)-
1605static SHELL_VAR *-
1606assign_dirstack (self, value, ind, key)-
1607 SHELL_VAR *self;-
1608 char *value;-
1609 arrayind_t ind;-
1610 char *key;-
1611{-
1612 set_dirstack_element (ind, 1, value);-
1613 return self;
executed 1 time by 1 test: return self;
Executed by:
  • Self test
1
1614}-
1615-
1616static SHELL_VAR *-
1617get_dirstack (self)-
1618 SHELL_VAR *self;-
1619{-
1620 ARRAY *a;-
1621 WORD_LIST *l;-
1622-
1623 l = get_directory_stack (0);-
1624 a = array_from_word_list (l);-
1625 array_dispose (array_cell (self));-
1626 dispose_words (l);-
1627 var_setarray (self, a);-
1628 return self;
executed 27 times by 1 test: return self;
Executed by:
  • Self test
27
1629}-
1630#endif /* PUSHD AND POPD && ARRAY_VARS */-
1631-
1632#if defined (ARRAY_VARS)-
1633/* We don't want to initialize the group set with a call to getgroups()-
1634 unless we're asked to, but we only want to do it once. */-
1635static SHELL_VAR *-
1636get_groupset (self)-
1637 SHELL_VAR *self;-
1638{-
1639 register int i;-
1640 int ng;-
1641 ARRAY *a;-
1642 static char **group_set = (char **)NULL;-
1643-
1644 if (group_set == 0)
group_set == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
1-5
1645 {-
1646 group_set = get_group_list (&ng);-
1647 a = array_cell (self);-
1648 for (i = 0; i < ng; i++)
i < ngDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-11
1649 array_insert (a, i, group_set[i]);
executed 11 times by 1 test: array_insert (a, i, group_set[i]);
Executed by:
  • Self test
11
1650 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
1651 return (self);
executed 6 times by 1 test: return (self);
Executed by:
  • Self test
6
1652}-
1653-
1654static SHELL_VAR *-
1655build_hashcmd (self)-
1656 SHELL_VAR *self;-
1657{-
1658 HASH_TABLE *h;-
1659 int i;-
1660 char *k, *v;-
1661 BUCKET_CONTENTS *item;-
1662-
1663 h = assoc_cell (self);-
1664 if (h)
hDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-10
1665 assoc_dispose (h);
executed 10 times by 1 test: assoc_dispose (h);
Executed by:
  • Self test
10
1666-
1667 if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0)
(hashed_filenames)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
hashed_filenames == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
((hashed_filen...ries : 0) == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
1668 {-
1669 var_setvalue (self, (char *)NULL);-
1670 return self;
executed 2 times by 1 test: return self;
Executed by:
  • Self test
2
1671 }-
1672-
1673 h = assoc_create (hashed_filenames->nbuckets);-
1674 for (i = 0; i < hashed_filenames->nbuckets; i++)
i < hashed_filenames->nbucketsDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-640
1675 {-
1676 for (item = hash_items (i, hashed_filenames); item; item = item->next)
itemDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 640 times by 1 test
Evaluated by:
  • Self test
30-640
1677 {-
1678 k = savestring (item->key);-
1679 v = pathdata(item)->path;-
1680 assoc_insert (h, k, v);-
1681 }
executed 30 times by 1 test: end of block
Executed by:
  • Self test
30
1682 }
executed 640 times by 1 test: end of block
Executed by:
  • Self test
640
1683-
1684 var_setvalue (self, (char *)h);-
1685 return self;
executed 10 times by 1 test: return self;
Executed by:
  • Self test
10
1686}-
1687-
1688static SHELL_VAR *-
1689get_hashcmd (self)-
1690 SHELL_VAR *self;-
1691{-
1692 build_hashcmd (self);-
1693 return (self);
executed 10 times by 1 test: return (self);
Executed by:
  • Self test
10
1694}-
1695-
1696static SHELL_VAR *-
1697assign_hashcmd (self, value, ind, key)-
1698 SHELL_VAR *self;-
1699 char *value;-
1700 arrayind_t ind;-
1701 char *key;-
1702{-
1703#if defined (RESTRICTED_SHELL)-
1704 char *full_path;-
1705-
1706 if (restricted)
restrictedDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1707 {-
1708 if (strchr (value, '/'))
(__extension__...alue , '/' )))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( '/' )Description
TRUEnever evaluated
FALSEnever evaluated
!__builtin_con...nt_p ( value )Description
TRUEnever evaluated
FALSEnever evaluated
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
1709 {-
1710 sh_restricted (value);-
1711 return (SHELL_VAR *)NULL;
never executed: return (SHELL_VAR *) ((void *)0) ;
0
1712 }-
1713 /* If we are changing the hash table in a restricted shell, make sure the-
1714 target pathname can be found using a $PATH search. */-
1715 full_path = find_user_command (value);-
1716 if (full_path == 0 || *full_path == 0 || executable_file (full_path) == 0)
full_path == 0Description
TRUEnever evaluated
FALSEnever evaluated
*full_path == 0Description
TRUEnever evaluated
FALSEnever evaluated
executable_fil...ull_path) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1717 {-
1718 sh_notfound (value);-
1719 free (full_path);-
1720 return ((SHELL_VAR *)NULL);
never executed: return ((SHELL_VAR *) ((void *)0) );
0
1721 }-
1722 free (full_path);-
1723 }
never executed: end of block
0
1724#endif-
1725 phash_insert (key, value, 0, 0);-
1726 return (build_hashcmd (self));
executed 2 times by 1 test: return (build_hashcmd (self));
Executed by:
  • Self test
2
1727}-
1728-
1729#if defined (ALIAS)-
1730static SHELL_VAR *-
1731build_aliasvar (self)-
1732 SHELL_VAR *self;-
1733{-
1734 HASH_TABLE *h;-
1735 int i;-
1736 char *k, *v;-
1737 BUCKET_CONTENTS *item;-
1738-
1739 h = assoc_cell (self);-
1740 if (h)
hDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-10
1741 assoc_dispose (h);
executed 10 times by 1 test: assoc_dispose (h);
Executed by:
  • Self test
10
1742-
1743 if (aliases == 0 || HASH_ENTRIES (aliases) == 0)
(aliases)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
aliases == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
((aliases) ? (...ries : 0) == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
1744 {-
1745 var_setvalue (self, (char *)NULL);-
1746 return self;
executed 2 times by 1 test: return self;
Executed by:
  • Self test
2
1747 }-
1748-
1749 h = assoc_create (aliases->nbuckets);-
1750 for (i = 0; i < aliases->nbuckets; i++)
i < aliases->nbucketsDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-640
1751 {-
1752 for (item = hash_items (i, aliases); item; item = item->next)
itemDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 640 times by 1 test
Evaluated by:
  • Self test
30-640
1753 {-
1754 k = savestring (item->key);-
1755 v = ((alias_t *)(item->data))->value;-
1756 assoc_insert (h, k, v);-
1757 }
executed 30 times by 1 test: end of block
Executed by:
  • Self test
30
1758 }
executed 640 times by 1 test: end of block
Executed by:
  • Self test
640
1759-
1760 var_setvalue (self, (char *)h);-
1761 return self;
executed 10 times by 1 test: return self;
Executed by:
  • Self test
10
1762}-
1763-
1764static SHELL_VAR *-
1765get_aliasvar (self)-
1766 SHELL_VAR *self;-
1767{-
1768 build_aliasvar (self);-
1769 return (self);
executed 10 times by 1 test: return (self);
Executed by:
  • Self test
10
1770}-
1771-
1772static SHELL_VAR *-
1773assign_aliasvar (self, value, ind, key)-
1774 SHELL_VAR *self;-
1775 char *value;-
1776 arrayind_t ind;-
1777 char *key;-
1778{-
1779 add_alias (key, value);-
1780 return (build_aliasvar (self));
executed 2 times by 1 test: return (build_aliasvar (self));
Executed by:
  • Self test
2
1781}-
1782#endif /* ALIAS */-
1783-
1784#endif /* ARRAY_VARS */-
1785-
1786/* If ARRAY_VARS is not defined, this just returns the name of any-
1787 currently-executing function. If we have arrays, it's a call stack. */-
1788static SHELL_VAR *-
1789get_funcname (self)-
1790 SHELL_VAR *self;-
1791{-
1792#if ! defined (ARRAY_VARS)-
1793 char *t;-
1794 if (variable_context && this_shell_function)-
1795 {-
1796 FREE (value_cell (self));-
1797 t = savestring (this_shell_function->name);-
1798 var_setvalue (self, t);-
1799 }-
1800#endif-
1801 return (self);
executed 6553497 times by 1 test: return (self);
Executed by:
  • Self test
6553497
1802}-
1803-
1804void-
1805make_funcname_visible (on_or_off)-
1806 int on_or_off;-
1807{-
1808 SHELL_VAR *v;-
1809-
1810 v = find_variable ("FUNCNAME");-
1811 if (v == 0 || v->dynamic_value == 0)
v == 0Description
TRUEnever evaluated
FALSEevaluated 3264159 times by 1 test
Evaluated by:
  • Self test
v->dynamic_value == 0Description
TRUEnever evaluated
FALSEevaluated 3264159 times by 1 test
Evaluated by:
  • Self test
0-3264159
1812 return;
never executed: return;
0
1813-
1814 if (on_or_off)
on_or_offDescription
TRUEevaluated 1640471 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1623688 times by 1 test
Evaluated by:
  • Self test
1623688-1640471
1815 VUNSETATTR (v, att_invisible);
executed 1640471 times by 1 test: ((v)->attributes &= ~(0x0001000));
Executed by:
  • Self test
1640471
1816 else-
1817 VSETATTR (v, att_invisible);
executed 1623688 times by 1 test: ((v)->attributes |= (0x0001000));
Executed by:
  • Self test
1623688
1818}-
1819-
1820static SHELL_VAR *-
1821init_funcname_var ()-
1822{-
1823 SHELL_VAR *v;-
1824-
1825 v = find_variable ("FUNCNAME");-
1826 if (v)
vDescription
TRUEnever evaluated
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
0-5447
1827 return v;
never executed: return v;
0
1828#if defined (ARRAY_VARS)-
1829 INIT_DYNAMIC_ARRAY_VAR ("FUNCNAME", get_funcname, null_array_assign);-
1830#else-
1831 INIT_DYNAMIC_VAR ("FUNCNAME", (char *)NULL, get_funcname, null_assign);-
1832#endif-
1833 VSETATTR (v, att_invisible|att_noassign);-
1834 return v;
executed 5447 times by 1 test: return v;
Executed by:
  • Self test
5447
1835}-
1836-
1837static void-
1838initialize_dynamic_variables ()-
1839{-
1840 SHELL_VAR *v;-
1841-
1842 v = init_seconds_var ();-
1843-
1844 INIT_DYNAMIC_VAR ("BASH_ARGV0", (char *)NULL, get_bash_argv0, assign_bash_argv0);-
1845-
1846 INIT_DYNAMIC_VAR ("BASH_COMMAND", (char *)NULL, get_bash_command, (sh_var_assign_func_t *)NULL);-
1847 INIT_DYNAMIC_VAR ("BASH_SUBSHELL", (char *)NULL, get_subshell, assign_subshell);-
1848-
1849 INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random);-
1850 VSETATTR (v, att_integer);-
1851 INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);-
1852 VSETATTR (v, att_integer|att_regenerate);-
1853-
1854 INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);-
1855 VSETATTR (v, att_integer);-
1856-
1857 INIT_DYNAMIC_VAR ("EPOCHSECONDS", (char *)NULL, get_epochseconds, null_assign);-
1858 VSETATTR (v, att_regenerate);-
1859 INIT_DYNAMIC_VAR ("EPOCHREALTIME", (char *)NULL, get_epochrealtime, null_assign);-
1860 VSETATTR (v, att_regenerate);-
1861-
1862#if defined (HISTORY)-
1863 INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);-
1864 VSETATTR (v, att_integer);-
1865#endif-
1866-
1867#if defined (READLINE)-
1868 INIT_DYNAMIC_VAR ("COMP_WORDBREAKS", (char *)NULL, get_comp_wordbreaks, assign_comp_wordbreaks);-
1869#endif-
1870-
1871#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)-
1872 v = init_dynamic_array_var ("DIRSTACK", get_dirstack, assign_dirstack, 0);-
1873#endif /* PUSHD_AND_POPD && ARRAY_VARS */-
1874-
1875#if defined (ARRAY_VARS)-
1876 v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign);-
1877-
1878# if defined (DEBUGGER)-
1879 v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign|att_nounset);-
1880 v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign|att_nounset);-
1881# endif /* DEBUGGER */-
1882 v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign|att_nounset);-
1883 v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset);-
1884-
1885 v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree);-
1886# if defined (ALIAS)-
1887 v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree);-
1888# endif-
1889#endif-
1890-
1891 v = init_funcname_var ();-
1892}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
1893-
1894/* **************************************************************** */-
1895/* */-
1896/* Retrieving variables and values */-
1897/* */-
1898/* **************************************************************** */-
1899-
1900/* How to get a pointer to the shell variable or function named NAME.-
1901 HASHED_VARS is a pointer to the hash table containing the list-
1902 of interest (either variables or functions). */-
1903-
1904static SHELL_VAR *-
1905hash_lookup (name, hashed_vars)-
1906 const char *name;-
1907 HASH_TABLE *hashed_vars;-
1908{-
1909 BUCKET_CONTENTS *bucket;-
1910-
1911 bucket = hash_search (name, hashed_vars, 0);-
1912 /* If we find the name in HASHED_VARS, set LAST_TABLE_SEARCHED to that-
1913 table. */-
1914 if (bucket)
bucketDescription
TRUEevaluated 317768149 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 290516185 times by 1 test
Evaluated by:
  • Self test
290516185-317768149
1915 last_table_searched = hashed_vars;
executed 317768149 times by 1 test: last_table_searched = hashed_vars;
Executed by:
  • Self test
317768149
1916 return (bucket ? (SHELL_VAR *)bucket->data : (SHELL_VAR *)NULL);
executed 608284334 times by 1 test: return (bucket ? (SHELL_VAR *)bucket->data : (SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
608284334
1917}-
1918-
1919SHELL_VAR *-
1920var_lookup (name, vcontext)-
1921 const char *name;-
1922 VAR_CONTEXT *vcontext;-
1923{-
1924 VAR_CONTEXT *vc;-
1925 SHELL_VAR *v;-
1926-
1927 v = (SHELL_VAR *)NULL;-
1928 for (vc = vcontext; vc; vc = vc->down)
vcDescription
TRUEevaluated 352391221 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1646277 times by 1 test
Evaluated by:
  • Self test
1646277-352391221
1929 if (v = hash_lookup (name, vc->table))
v = hash_looku...me, vc->table)Description
TRUEevaluated 199428273 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 152962948 times by 1 test
Evaluated by:
  • Self test
152962948-199428273
1930 break;
executed 199428273 times by 1 test: break;
Executed by:
  • Self test
199428273
1931-
1932 return v;
executed 201074550 times by 1 test: return v;
Executed by:
  • Self test
201074550
1933}-
1934-
1935/* Look up the variable entry named NAME. If SEARCH_TEMPENV is non-zero,-
1936 then also search the temporarily built list of exported variables.-
1937 The lookup order is:-
1938 temporary_env-
1939 shell_variables list-
1940*/-
1941-
1942SHELL_VAR *-
1943find_variable_internal (name, flags)-
1944 const char *name;-
1945 int flags;-
1946{-
1947 SHELL_VAR *var;-
1948 int search_tempenv, force_tempenv;-
1949 VAR_CONTEXT *vc;-
1950-
1951 var = (SHELL_VAR *)NULL;-
1952-
1953 force_tempenv = (flags & FV_FORCETEMPENV);-
1954-
1955 /* If explicitly requested, first look in the temporary environment for-
1956 the variable. This allows constructs such as "foo=x eval 'echo $foo'"-
1957 to get the `exported' value of $foo. This happens if we are executing-
1958 a function or builtin, or if we are looking up a variable in a-
1959 "subshell environment". */-
1960 search_tempenv = force_tempenv || (expanding_redir == 0 && subshell_environment);
force_tempenvDescription
TRUEevaluated 36498286 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 164543196 times by 1 test
Evaluated by:
  • Self test
expanding_redir == 0Description
TRUEevaluated 162551006 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1992190 times by 1 test
Evaluated by:
  • Self test
subshell_environmentDescription
TRUEevaluated 56514 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 162494492 times by 1 test
Evaluated by:
  • Self test
56514-164543196
1961-
1962 if (search_tempenv && temporary_env)
search_tempenvDescription
TRUEevaluated 36554800 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 164486682 times by 1 test
Evaluated by:
  • Self test
temporary_envDescription
TRUEevaluated 6885 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36547915 times by 1 test
Evaluated by:
  • Self test
6885-164486682
1963 var = hash_lookup (name, temporary_env);
executed 6885 times by 1 test: var = hash_lookup (name, temporary_env);
Executed by:
  • Self test
6885
1964-
1965 if (var == 0)
var == 0Description
TRUEevaluated 201038167 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3315 times by 1 test
Evaluated by:
  • Self test
3315-201038167
1966 {-
1967 if ((flags & FV_SKIPINVISIBLE) == 0)
(flags & 0x02) == 0Description
TRUEevaluated 201038167 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-201038167
1968 var = var_lookup (name, shell_variables);
executed 201038167 times by 1 test: var = var_lookup (name, shell_variables);
Executed by:
  • Self test
201038167
1969 else-
1970 {-
1971 /* essentially var_lookup expanded inline so we can check for-
1972 att_invisible */-
1973 for (vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEnever evaluated
FALSEnever evaluated
0
1974 {-
1975 var = hash_lookup (name, vc->table);-
1976 if (var && invisible_p (var))
varDescription
TRUEnever evaluated
FALSEnever evaluated
((((var)->attr... (0x0001000)))Description
TRUEnever evaluated
FALSEnever evaluated
0
1977 var = 0;
never executed: var = 0;
0
1978 if (var)
varDescription
TRUEnever evaluated
FALSEnever evaluated
0
1979 break;
never executed: break;
0
1980 }
never executed: end of block
0
1981 }
never executed: end of block
0
1982 }-
1983-
1984 if (var == 0)
var == 0Description
TRUEevaluated 1627791 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 199413691 times by 1 test
Evaluated by:
  • Self test
1627791-199413691
1985 return ((SHELL_VAR *)NULL);
executed 1627791 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
1627791
1986-
1987 return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
executed 199413691 times by 1 test: return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
Executed by:
  • Self test
199413691
1988}-
1989-
1990/* Look up and resolve the chain of nameref variables starting at V all the-
1991 way to NULL or non-nameref. */-
1992SHELL_VAR *-
1993find_variable_nameref (v)-
1994 SHELL_VAR *v;-
1995{-
1996 int level, flags;-
1997 char *newname;-
1998 SHELL_VAR *orig, *oldv;-
1999-
2000 level = 0;-
2001 orig = v;-
2002 while (v && nameref_p (v))
vDescription
TRUEevaluated 480 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 83 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 331 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 149 times by 1 test
Evaluated by:
  • Self test
83-480
2003 {-
2004 level++;-
2005 if (level > NAMEREF_MAX)
level > 8Description
TRUEnever evaluated
FALSEevaluated 331 times by 1 test
Evaluated by:
  • Self test
0-331
2006 return ((SHELL_VAR *)0); /* error message here? */
never executed: return ((SHELL_VAR *)0);
0
2007 newname = nameref_cell (v);-
2008 if (newname == 0 || *newname == '\0')
newname == 0Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 249 times by 1 test
Evaluated by:
  • Self test
*newname == '\0'Description
TRUEnever evaluated
FALSEevaluated 249 times by 1 test
Evaluated by:
  • Self test
0-249
2009 return ((SHELL_VAR *)0);
executed 82 times by 1 test: return ((SHELL_VAR *)0);
Executed by:
  • Self test
82
2010 oldv = v;-
2011 flags = 0;-
2012 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEevaluated 249 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
assigning_in_environmentDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 232 times by 1 test
Evaluated by:
  • Self test
executing_builtinDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 173 times by 1 test
Evaluated by:
  • Self test
0-249
2013 flags |= FV_FORCETEMPENV;
executed 76 times by 1 test: flags |= 0x01;
Executed by:
  • Self test
76
2014 /* We don't handle array subscripts here. */-
2015 v = find_variable_internal (newname, flags);-
2016 if (v == orig || v == oldv)
v == origDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 245 times by 1 test
Evaluated by:
  • Self test
v == oldvDescription
TRUEnever evaluated
FALSEevaluated 245 times by 1 test
Evaluated by:
  • Self test
0-245
2017 {-
2018 internal_warning (_("%s: circular name reference"), orig->name);-
2019#if 1-
2020 /* XXX - provisional change - bash-5.0 - circular refs go to-
2021 global scope for resolution, without namerefs. */-
2022 if (variable_context && v->context)
variable_contextDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
v->contextDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
2023 return (find_global_variable_noref (v->name));
executed 2 times by 1 test: return (find_global_variable_noref (v->name));
Executed by:
  • Self test
2
2024 else-
2025#endif-
2026 return ((SHELL_VAR *)0);
executed 2 times by 1 test: return ((SHELL_VAR *)0);
Executed by:
  • Self test
2
2027 }-
2028 }
executed 245 times by 1 test: end of block
Executed by:
  • Self test
245
2029 return v;
executed 232 times by 1 test: return v;
Executed by:
  • Self test
232
2030}-
2031-
2032/* Resolve the chain of nameref variables for NAME. XXX - could change later */-
2033SHELL_VAR *-
2034find_variable_last_nameref (name, vflags)-
2035 const char *name;-
2036 int vflags;-
2037{-
2038 SHELL_VAR *v, *nv;-
2039 char *newname;-
2040 int level, flags;-
2041-
2042 nv = v = find_variable_noref (name);-
2043 level = 0;-
2044 while (v && nameref_p (v))
vDescription
TRUEevaluated 5444914 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24801 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 341 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5444573 times by 1 test
Evaluated by:
  • Self test
341-5444914
2045 {-
2046 level++;-
2047 if (level > NAMEREF_MAX)
level > 8Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 338 times by 1 test
Evaluated by:
  • Self test
3-338
2048 return ((SHELL_VAR *)0); /* error message here? */
executed 3 times by 1 test: return ((SHELL_VAR *)0);
Executed by:
  • Self test
3
2049 newname = nameref_cell (v);-
2050 if (newname == 0 || *newname == '\0')
newname == 0Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 210 times by 1 test
Evaluated by:
  • Self test
*newname == '\0'Description
TRUEnever evaluated
FALSEevaluated 210 times by 1 test
Evaluated by:
  • Self test
0-210
2051 return ((vflags && invisible_p (v)) ? v : (SHELL_VAR *)0);
executed 128 times by 1 test: return ((vflags && ((((v)->attributes) & (0x0001000)))) ? v : (SHELL_VAR *)0);
Executed by:
  • Self test
128
2052 nv = v;-
2053 flags = 0;-
2054 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEevaluated 210 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
assigning_in_environmentDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
executing_builtinDescription
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 101 times by 1 test
Evaluated by:
  • Self test
0-210
2055 flags |= FV_FORCETEMPENV;
executed 109 times by 1 test: flags |= 0x01;
Executed by:
  • Self test
109
2056 /* We don't accommodate array subscripts here. */-
2057 v = find_variable_internal (newname, flags);-
2058 }
executed 210 times by 1 test: end of block
Executed by:
  • Self test
210
2059 return nv;
executed 5469374 times by 1 test: return nv;
Executed by:
  • Self test
5469374
2060}-
2061-
2062/* Resolve the chain of nameref variables for NAME. XXX - could change later */-
2063SHELL_VAR *-
2064find_global_variable_last_nameref (name, vflags)-
2065 const char *name;-
2066 int vflags;-
2067{-
2068 SHELL_VAR *v, *nv;-
2069 char *newname;-
2070 int level;-
2071-
2072 nv = v = find_global_variable_noref (name);-
2073 level = 0;-
2074 while (v && nameref_p (v))
vDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
2075 {-
2076 level++;-
2077 if (level > NAMEREF_MAX)
level > 8Description
TRUEnever evaluated
FALSEnever evaluated
0
2078 return ((SHELL_VAR *)0); /* error message here? */
never executed: return ((SHELL_VAR *)0);
0
2079 newname = nameref_cell (v);-
2080 if (newname == 0 || *newname == '\0')
newname == 0Description
TRUEnever evaluated
FALSEnever evaluated
*newname == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
2081 return ((vflags && invisible_p (v)) ? v : (SHELL_VAR *)0);
never executed: return ((vflags && ((((v)->attributes) & (0x0001000)))) ? v : (SHELL_VAR *)0);
0
2082 nv = v;-
2083 /* We don't accommodate array subscripts here. */-
2084 v = find_global_variable_noref (newname);-
2085 }
never executed: end of block
0
2086 return nv;
executed 46 times by 1 test: return nv;
Executed by:
  • Self test
46
2087}-
2088-
2089static SHELL_VAR *-
2090find_nameref_at_context (v, vc)-
2091 SHELL_VAR *v;-
2092 VAR_CONTEXT *vc;-
2093{-
2094 SHELL_VAR *nv, *nv2;-
2095 char *newname;-
2096 int level;-
2097-
2098 nv = v;-
2099 level = 1;-
2100 while (nv && nameref_p (nv))
nvDescription
TRUEevaluated 98 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((nv)->attri... (0x0000800)))Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-98
2101 {-
2102 level++;-
2103 if (level > NAMEREF_MAX)
level > 8Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 87 times by 1 test
Evaluated by:
  • Self test
6-87
2104 return (&nameref_maxloop_value);
executed 6 times by 1 test: return (&nameref_maxloop_value);
Executed by:
  • Self test
6
2105 newname = nameref_cell (nv);-
2106 if (newname == 0 || *newname == '\0')
newname == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
*newname == '\0'Description
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
0-71
2107 return ((SHELL_VAR *)NULL);
executed 16 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
16
2108 nv2 = hash_lookup (newname, vc->table);-
2109 if (nv2 == 0)
nv2 == 0Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test
24-47
2110 break;
executed 24 times by 1 test: break;
Executed by:
  • Self test
24
2111 nv = nv2;-
2112 }
executed 47 times by 1 test: end of block
Executed by:
  • Self test
47
2113 return nv;
executed 29 times by 1 test: return nv;
Executed by:
  • Self test
29
2114}-
2115-
2116/* Do nameref resolution from the VC, which is the local context for some-
2117 function or builtin, `up' the chain to the global variables context. If-
2118 NVCP is not NULL, return the variable context where we finally ended the-
2119 nameref resolution (so the bind_variable_internal can use the correct-
2120 variable context and hash table). */-
2121static SHELL_VAR *-
2122find_variable_nameref_context (v, vc, nvcp)-
2123 SHELL_VAR *v;-
2124 VAR_CONTEXT *vc;-
2125 VAR_CONTEXT **nvcp;-
2126{-
2127 SHELL_VAR *nv, *nv2;-
2128 VAR_CONTEXT *nvc;-
2129-
2130 /* Look starting at the current context all the way `up' */-
2131 for (nv = v, nvc = vc; nvc; nvc = nvc->down)
nvcDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-33
2132 {-
2133 nv2 = find_nameref_at_context (nv, nvc);-
2134 if (nv2 == &nameref_maxloop_value)
nv2 == &nameref_maxloop_valueDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
6-27
2135 return (nv2); /* XXX */
executed 6 times by 1 test: return (nv2);
Executed by:
  • Self test
6
2136 if (nv2 == 0)
nv2 == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
8-19
2137 continue;
executed 8 times by 1 test: continue;
Executed by:
  • Self test
8
2138 nv = nv2;-
2139 if (*nvcp)
*nvcpDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-19
2140 *nvcp = nvc;
executed 19 times by 1 test: *nvcp = nvc;
Executed by:
  • Self test
19
2141 if (nameref_p (nv) == 0)
((((nv)->attri...000800))) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
5-14
2142 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
2143 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
2144 return (nameref_p (nv) ? (SHELL_VAR *)NULL : nv);
executed 14 times by 1 test: return (((((nv)->attributes) & (0x0000800))) ? (SHELL_VAR *) ((void *)0) : nv);
Executed by:
  • Self test
14
2145}-
2146-
2147/* Do nameref resolution from the VC, which is the local context for some-
2148 function or builtin, `up' the chain to the global variables context. If-
2149 NVCP is not NULL, return the variable context where we finally ended the-
2150 nameref resolution (so the bind_variable_internal can use the correct-
2151 variable context and hash table). */-
2152static SHELL_VAR *-
2153find_variable_last_nameref_context (v, vc, nvcp)-
2154 SHELL_VAR *v;-
2155 VAR_CONTEXT *vc;-
2156 VAR_CONTEXT **nvcp;-
2157{-
2158 SHELL_VAR *nv, *nv2;-
2159 VAR_CONTEXT *nvc;-
2160-
2161 /* Look starting at the current context all the way `up' */-
2162 for (nv = v, nvc = vc; nvc; nvc = nvc->down)
nvcDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-18
2163 {-
2164 nv2 = find_nameref_at_context (nv, nvc);-
2165 if (nv2 == &nameref_maxloop_value)
nv2 == &nameref_maxloop_valueDescription
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-18
2166 return (nv2); /* XXX */
never executed: return (nv2);
0
2167 if (nv2 == 0)
nv2 == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
8-10
2168 continue;
executed 8 times by 1 test: continue;
Executed by:
  • Self test
8
2169 nv = nv2;-
2170 if (*nvcp)
*nvcpDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
2171 *nvcp = nvc;
executed 10 times by 1 test: *nvcp = nvc;
Executed by:
  • Self test
10
2172 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test
10
2173 return (nameref_p (nv) ? nv : (SHELL_VAR *)NULL);
executed 9 times by 1 test: return (((((nv)->attributes) & (0x0000800))) ? nv : (SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
9
2174}-
2175-
2176SHELL_VAR *-
2177find_variable_nameref_for_create (name, flags)-
2178 const char *name;-
2179 int flags;-
2180{-
2181 SHELL_VAR *var;-
2182-
2183 /* See if we have a nameref pointing to a variable that hasn't been-
2184 created yet. */-
2185 var = find_variable_last_nameref (name, 1);-
2186 if ((flags&1) && var && nameref_p (var) && invisible_p (var))
(flags&1)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
varDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0001000)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-54
2187 {-
2188 internal_warning (_("%s: removing nameref attribute"), name);-
2189 VUNSETATTR (var, att_nameref);-
2190 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
2191 if (var && nameref_p (var))
varDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
5-52
2192 {-
2193 if (legal_identifier (nameref_cell (var)) == 0)
legal_identifi...->value)) == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-7
2194 {-
2195 sh_invalidid (nameref_cell (var) ? nameref_cell (var) : "");-
2196 return ((SHELL_VAR *)INVALID_NAMEREF_VALUE);
executed 7 times by 1 test: return ((SHELL_VAR *)(void *)&nameref_invalid_value);
Executed by:
  • Self test
7
2197 }-
2198 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
2199 return (var);
executed 60 times by 1 test: return (var);
Executed by:
  • Self test
60
2200}-
2201-
2202SHELL_VAR *-
2203find_variable_nameref_for_assignment (name, flags)-
2204 const char *name;-
2205 int flags;-
2206{-
2207 SHELL_VAR *var;-
2208-
2209 /* See if we have a nameref pointing to a variable that hasn't been-
2210 created yet. */-
2211 var = find_variable_last_nameref (name, 1);-
2212 if (var && nameref_p (var) && invisible_p (var)) /* XXX - flags */
varDescription
TRUEnever evaluated
FALSEnever evaluated
((((var)->attr... (0x0000800)))Description
TRUEnever evaluated
FALSEnever evaluated
((((var)->attr... (0x0001000)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2213 {-
2214 internal_warning (_("%s: removing nameref attribute"), name);-
2215 VUNSETATTR (var, att_nameref);-
2216 }
never executed: end of block
0
2217 if (var && nameref_p (var))
varDescription
TRUEnever evaluated
FALSEnever evaluated
((((var)->attr... (0x0000800)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2218 {-
2219 if (valid_nameref_value (nameref_cell (var), 1) == 0)
valid_nameref_...alue), 1) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2220 {-
2221 sh_invalidid (nameref_cell (var) ? nameref_cell (var) : "");-
2222 return ((SHELL_VAR *)INVALID_NAMEREF_VALUE);
never executed: return ((SHELL_VAR *)(void *)&nameref_invalid_value);
0
2223 }-
2224 }
never executed: end of block
0
2225 return (var);
never executed: return (var);
0
2226}-
2227-
2228/* Find a variable, forcing a search of the temporary environment first */-
2229SHELL_VAR *-
2230find_variable_tempenv (name)-
2231 const char *name;-
2232{-
2233 SHELL_VAR *var;-
2234-
2235 var = find_variable_internal (name, FV_FORCETEMPENV);-
2236 if (var && nameref_p (var))
varDescription
TRUEevaluated 27788 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEnever evaluated
FALSEevaluated 27788 times by 1 test
Evaluated by:
  • Self test
0-27788
2237 var = find_variable_nameref (var);
never executed: var = find_variable_nameref (var);
0
2238 return (var);
executed 27857 times by 1 test: return (var);
Executed by:
  • Self test
27857
2239}-
2240-
2241/* Find a variable, not forcing a search of the temporary environment first */-
2242SHELL_VAR *-
2243find_variable_notempenv (name)-
2244 const char *name;-
2245{-
2246 SHELL_VAR *var;-
2247-
2248 var = find_variable_internal (name, 0);-
2249 if (var && nameref_p (var))
varDescription
TRUEevaluated 2582 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2576 times by 1 test
Evaluated by:
  • Self test
4-2582
2250 var = find_variable_nameref (var);
executed 6 times by 1 test: var = find_variable_nameref (var);
Executed by:
  • Self test
6
2251 return (var);
executed 2586 times by 1 test: return (var);
Executed by:
  • Self test
2586
2252}-
2253-
2254SHELL_VAR *-
2255find_global_variable (name)-
2256 const char *name;-
2257{-
2258 SHELL_VAR *var;-
2259-
2260 var = var_lookup (name, global_variables);-
2261 if (var && nameref_p (var))
varDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 56 times by 1 test
Evaluated by:
  • Self test
21-77
2262 var = find_variable_nameref (var);
executed 21 times by 1 test: var = find_variable_nameref (var);
Executed by:
  • Self test
21
2263-
2264 if (var == 0)
var == 0Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
34-64
2265 return ((SHELL_VAR *)NULL);
executed 34 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
34
2266-
2267 return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
executed 64 times by 1 test: return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
Executed by:
  • Self test
64
2268}-
2269-
2270SHELL_VAR *-
2271find_global_variable_noref (name)-
2272 const char *name;-
2273{-
2274 SHELL_VAR *var;-
2275-
2276 var = var_lookup (name, global_variables);-
2277-
2278 if (var == 0)
var == 0Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
18-30
2279 return ((SHELL_VAR *)NULL);
executed 18 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
18
2280-
2281 return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
executed 30 times by 1 test: return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
Executed by:
  • Self test
30
2282}-
2283-
2284SHELL_VAR *-
2285find_shell_variable (name)-
2286 const char *name;-
2287{-
2288 SHELL_VAR *var;-
2289-
2290 var = var_lookup (name, shell_variables);-
2291 if (var && nameref_p (var))
varDescription
TRUEevaluated 10391 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10375 times by 1 test
Evaluated by:
  • Self test
16-10391
2292 var = find_variable_nameref (var);
executed 16 times by 1 test: var = find_variable_nameref (var);
Executed by:
  • Self test
16
2293-
2294 if (var == 0)
var == 0Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10384 times by 1 test
Evaluated by:
  • Self test
48-10384
2295 return ((SHELL_VAR *)NULL);
executed 48 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
48
2296-
2297 return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
executed 10384 times by 1 test: return (var->dynamic_value ? (*(var->dynamic_value)) (var) : var);
Executed by:
  • Self test
10384
2298}-
2299-
2300/* Look up the variable entry named NAME. Returns the entry or NULL. */-
2301SHELL_VAR *-
2302find_variable (name)-
2303 const char *name;-
2304{-
2305 SHELL_VAR *v;-
2306 int flags;-
2307-
2308 last_table_searched = 0;-
2309 flags = 0;-
2310 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEevaluated 193547358 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1992186 times by 1 test
Evaluated by:
  • Self test
assigning_in_environmentDescription
TRUEevaluated 6878 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 193540480 times by 1 test
Evaluated by:
  • Self test
executing_builtinDescription
TRUEevaluated 36454321 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 157086159 times by 1 test
Evaluated by:
  • Self test
6878-193547358
2311 flags |= FV_FORCETEMPENV;
executed 36461199 times by 1 test: flags |= 0x01;
Executed by:
  • Self test
36461199
2312 v = find_variable_internal (name, flags);-
2313 if (v && nameref_p (v))
vDescription
TRUEevaluated 193937406 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1602138 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 266 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 193937140 times by 1 test
Evaluated by:
  • Self test
266-193937406
2314 v = find_variable_nameref (v);
executed 266 times by 1 test: v = find_variable_nameref (v);
Executed by:
  • Self test
266
2315 return v;
executed 195539544 times by 1 test: return v;
Executed by:
  • Self test
195539544
2316}-
2317-
2318/* Find the first instance of NAME in the variable context chain; return first-
2319 one found without att_invisible set; return 0 if no non-invisible instances-
2320 found. */-
2321SHELL_VAR *-
2322find_variable_no_invisible (name)-
2323 const char *name;-
2324{-
2325 SHELL_VAR *v;-
2326 int flags;-
2327-
2328 last_table_searched = 0;-
2329 flags = FV_SKIPINVISIBLE;-
2330 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEnever evaluated
FALSEnever evaluated
assigning_in_environmentDescription
TRUEnever evaluated
FALSEnever evaluated
executing_builtinDescription
TRUEnever evaluated
FALSEnever evaluated
0
2331 flags |= FV_FORCETEMPENV;
never executed: flags |= 0x01;
0
2332 v = find_variable_internal (name, flags);-
2333 if (v && nameref_p (v))
vDescription
TRUEnever evaluated
FALSEnever evaluated
((((v)->attrib... (0x0000800)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2334 v = find_variable_nameref (v);
never executed: v = find_variable_nameref (v);
0
2335 return v;
never executed: return v;
0
2336}-
2337-
2338/* Find the first instance of NAME in the variable context chain; return first-
2339 one found even if att_invisible set. */-
2340SHELL_VAR *-
2341find_variable_for_assignment (name)-
2342 const char *name;-
2343{-
2344 SHELL_VAR *v;-
2345 int flags;-
2346-
2347 last_table_searched = 0;-
2348 flags = 0;-
2349 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEnever evaluated
FALSEnever evaluated
assigning_in_environmentDescription
TRUEnever evaluated
FALSEnever evaluated
executing_builtinDescription
TRUEnever evaluated
FALSEnever evaluated
0
2350 flags |= FV_FORCETEMPENV;
never executed: flags |= 0x01;
0
2351 v = find_variable_internal (name, flags);-
2352 if (v && nameref_p (v))
vDescription
TRUEnever evaluated
FALSEnever evaluated
((((v)->attrib... (0x0000800)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2353 v = find_variable_nameref (v);
never executed: v = find_variable_nameref (v);
0
2354 return v;
never executed: return v;
0
2355}-
2356-
2357SHELL_VAR *-
2358find_variable_noref (name)-
2359 const char *name;-
2360{-
2361 SHELL_VAR *v;-
2362 int flags;-
2363-
2364 flags = 0;-
2365 if (expanding_redir == 0 && (assigning_in_environment || executing_builtin))
expanding_redir == 0Description
TRUEevaluated 5471032 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
assigning_in_environmentDescription
TRUEevaluated 1532 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5469500 times by 1 test
Evaluated by:
  • Self test
executing_builtinDescription
TRUEevaluated 7513 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5461987 times by 1 test
Evaluated by:
  • Self test
4-5471032
2366 flags |= FV_FORCETEMPENV;
executed 9045 times by 1 test: flags |= 0x01;
Executed by:
  • Self test
9045
2367 v = find_variable_internal (name, flags);-
2368 return v;
executed 5471036 times by 1 test: return v;
Executed by:
  • Self test
5471036
2369}-
2370-
2371/* Look up the function entry whose name matches STRING.-
2372 Returns the entry or NULL. */-
2373SHELL_VAR *-
2374find_function (name)-
2375 const char *name;-
2376{-
2377 return (hash_lookup (name, shell_functions));
executed 34751686 times by 1 test: return (hash_lookup (name, shell_functions));
Executed by:
  • Self test
34751686
2378}-
2379-
2380/* Find the function definition for the shell function named NAME. Returns-
2381 the entry or NULL. */-
2382FUNCTION_DEF *-
2383find_function_def (name)-
2384 const char *name;-
2385{-
2386#if defined (DEBUGGER)-
2387 return ((FUNCTION_DEF *)hash_lookup (name, shell_function_defs));
executed 1662836 times by 1 test: return ((FUNCTION_DEF *)hash_lookup (name, shell_function_defs));
Executed by:
  • Self test
1662836
2388#else-
2389 return ((FUNCTION_DEF *)0);-
2390#endif-
2391}-
2392-
2393/* Return the value of VAR. VAR is assumed to have been the result of a-
2394 lookup without any subscript, if arrays are compiled into the shell. */-
2395char *-
2396get_variable_value (var)-
2397 SHELL_VAR *var;-
2398{-
2399 if (var == 0)
var == 0Description
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7299711 times by 1 test
Evaluated by:
  • Self test
94-7299711
2400 return ((char *)NULL);
executed 94 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
94
2401#if defined (ARRAY_VARS)-
2402 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7299692 times by 1 test
Evaluated by:
  • Self test
19-7299692
2403 return (array_reference (array_cell (var), 0));
executed 19 times by 1 test: return (array_reference ((ARRAY *)((var)->value), 0));
Executed by:
  • Self test
19
2404 else if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 7299692 times by 1 test
Evaluated by:
  • Self test
0-7299692
2405 return (assoc_reference (assoc_cell (var), "0"));
never executed: return (assoc_reference ((HASH_TABLE *)((var)->value), "0"));
0
2406#endif-
2407 else-
2408 return (value_cell (var));
executed 7299692 times by 1 test: return (((var)->value));
Executed by:
  • Self test
7299692
2409}-
2410-
2411/* Return the string value of a variable. Return NULL if the variable-
2412 doesn't exist. Don't cons a new string. This is a potential memory-
2413 leak if the variable is found in the temporary environment, but doesn't-
2414 leak in practice. Since functions and variables have separate name-
2415 spaces, returns NULL if var_name is a shell function only. */-
2416char *-
2417get_string_value (var_name)-
2418 const char *var_name;-
2419{-
2420 SHELL_VAR *var;-
2421-
2422 var = find_variable (var_name);-
2423 return ((var) ? get_variable_value (var) : (char *)NULL);
executed 1482994 times by 1 test: return ((var) ? get_variable_value (var) : (char *) ((void *)0) );
Executed by:
  • Self test
1482994
2424}-
2425-
2426/* This is present for use by the tilde and readline libraries. */-
2427char *-
2428sh_get_env_value (v)-
2429 const char *v;-
2430{-
2431 return get_string_value (v);
executed 55 times by 1 test: return get_string_value (v);
Executed by:
  • Self test
55
2432}-
2433-
2434/* **************************************************************** */-
2435/* */-
2436/* Creating and setting variables */-
2437/* */-
2438/* **************************************************************** */-
2439-
2440/* Set NAME to VALUE if NAME has no value. */-
2441SHELL_VAR *-
2442set_if_not (name, value)-
2443 char *name, *value;-
2444{-
2445 SHELL_VAR *v;-
2446-
2447 if (shell_variables == 0)
shell_variables == 0Description
TRUEnever evaluated
FALSEevaluated 43650 times by 1 test
Evaluated by:
  • Self test
0-43650
2448 create_variable_tables ();
never executed: create_variable_tables ();
0
2449-
2450 v = find_variable (name);-
2451 if (v == 0)
v == 0Description
TRUEevaluated 32850 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10800 times by 1 test
Evaluated by:
  • Self test
10800-32850
2452 v = bind_variable_internal (name, value, global_variables->table, HASH_NOSRCH, 0);
executed 32850 times by 1 test: v = bind_variable_internal (name, value, global_variables->table, 0x01, 0);
Executed by:
  • Self test
32850
2453 return (v);
executed 43650 times by 1 test: return (v);
Executed by:
  • Self test
43650
2454}-
2455-
2456/* Create a local variable referenced by NAME. */-
2457SHELL_VAR *-
2458make_local_variable (name, flags)-
2459 const char *name;-
2460 int flags;-
2461{-
2462 SHELL_VAR *new_var, *old_var, *old_ref;-
2463 VAR_CONTEXT *vc;-
2464 int was_tmpvar;-
2465 char *old_value;-
2466-
2467 /* We don't want to follow the nameref chain when making local variables; we-
2468 just want to create them. */-
2469 old_ref = find_variable_noref (name);-
2470 if (old_ref && nameref_p (old_ref) == 0)
old_refDescription
TRUEevaluated 237 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 454 times by 1 test
Evaluated by:
  • Self test
((((old_ref)->...000800))) == 0Description
TRUEevaluated 228 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-454
2471 old_ref = 0;
executed 228 times by 1 test: old_ref = 0;
Executed by:
  • Self test
228
2472 /* local foo; local foo; is a no-op. */-
2473 old_var = find_variable (name);-
2474 if (old_ref == 0 && old_var && local_p (old_var) && old_var->context == variable_context)
old_ref == 0Description
TRUEevaluated 682 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
old_varDescription
TRUEevaluated 228 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 454 times by 1 test
Evaluated by:
  • Self test
((((old_var)->... (0x0000020)))Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
old_var->conte...riable_contextDescription
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test
9-682
2475 return (old_var);
executed 125 times by 1 test: return (old_var);
Executed by:
  • Self test
125
2476-
2477 /* local -n foo; local -n foo; is a no-op. */-
2478 if (old_ref && local_p (old_ref) && old_ref->context == variable_context)
old_refDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 557 times by 1 test
Evaluated by:
  • Self test
((((old_ref)->... (0x0000020)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
old_ref->conte...riable_contextDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-557
2479 return (old_ref);
executed 5 times by 1 test: return (old_ref);
Executed by:
  • Self test
5
2480-
2481 /* From here on, we want to use the refvar, not the variable it references */-
2482 if (old_ref)
old_refDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 557 times by 1 test
Evaluated by:
  • Self test
4-557
2483 old_var = old_ref;
executed 4 times by 1 test: old_var = old_ref;
Executed by:
  • Self test
4
2484-
2485 was_tmpvar = old_var && tempvar_p (old_var);
old_varDescription
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 454 times by 1 test
Evaluated by:
  • Self test
((((old_var)->... (0x0100000)))Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 81 times by 1 test
Evaluated by:
  • Self test
26-454
2486 /* If we're making a local variable in a shell function, the temporary env-
2487 has already been merged into the function's variable context stack. We-
2488 can assume that a temporary var in the same context appears in the same-
2489 VAR_CONTEXT and can safely be returned without creating a new variable-
2490 (which results in duplicate names in the same VAR_CONTEXT->table */-
2491 /* We can't just test tmpvar_p because variables in the temporary env given-
2492 to a shell function appear in the function's local variable VAR_CONTEXT-
2493 but retain their tempvar attribute. We want temporary variables that are-
2494 found in temporary_env, hence the test for last_table_searched, which is-
2495 set in hash_lookup and only (so far) checked here. */-
2496 if (was_tmpvar && old_var->context == variable_context && last_table_searched != temporary_env)
was_tmpvarDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 535 times by 1 test
Evaluated by:
  • Self test
old_var->conte...riable_contextDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
last_table_sea... temporary_envDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-535
2497 {-
2498 VUNSETATTR (old_var, att_invisible); /* XXX */-
2499 return (old_var);
executed 23 times by 1 test: return (old_var);
Executed by:
  • Self test
23
2500 }-
2501-
2502 /* If we want to change to "inherit the old variable's value" semantics,-
2503 here is where to save the old value. */-
2504 old_value = was_tmpvar ? value_cell (old_var) : (char *)NULL;
was_tmpvarDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 535 times by 1 test
Evaluated by:
  • Self test
3-535
2505-
2506 for (vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEevaluated 538 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-538
2507 if (vc_isfuncenv (vc) && vc->scope == variable_context)
(((vc)->flags & 0x04) != 0)Description
TRUEevaluated 538 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
vc->scope == variable_contextDescription
TRUEevaluated 538 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-538
2508 break;
executed 538 times by 1 test: break;
Executed by:
  • Self test
538
2509-
2510 if (vc == 0)
vc == 0Description
TRUEnever evaluated
FALSEevaluated 538 times by 1 test
Evaluated by:
  • Self test
0-538
2511 {-
2512 internal_error (_("make_local_variable: no function context at current scope"));-
2513 return ((SHELL_VAR *)NULL);
never executed: return ((SHELL_VAR *) ((void *)0) );
0
2514 }-
2515 else if (vc->table == 0)
vc->table == 0Description
TRUEevaluated 274 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 264 times by 1 test
Evaluated by:
  • Self test
264-274
2516 vc->table = hash_create (TEMPENV_HASH_BUCKETS);
executed 274 times by 1 test: vc->table = hash_create (4);
Executed by:
  • Self test
274
2517-
2518 /* Since this is called only from the local/declare/typeset code, we can-
2519 call builtin_error here without worry (of course, it will also work-
2520 for anything that sets this_command_name). Variables with the `noassign'-
2521 attribute may not be made local. The test against old_var's context-
2522 level is to disallow local copies of readonly global variables (since I-
2523 believe that this could be a security hole). Readonly copies of calling-
2524 function local variables are OK. */-
2525 if (old_var && (noassign_p (old_var) ||
old_varDescription
TRUEevaluated 84 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 454 times by 1 test
Evaluated by:
  • Self test
((((old_var)->... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 84 times by 1 test
Evaluated by:
  • Self test
0-454
2526 (readonly_p (old_var) && old_var->context == 0)))
((((old_var)->... (0x0000002)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
old_var->context == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-82
2527 {-
2528 if (readonly_p (old_var))
((((old_var)->... (0x0000002)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
2529 sh_readonly (name);
executed 2 times by 1 test: sh_readonly (name);
Executed by:
  • Self test
2
2530 else if (noassign_p (old_var))
((((old_var)->... (0x0004000)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2531 builtin_error (_("%s: variable may not be assigned value"), name);
never executed: builtin_error ( dcgettext (((void *)0), "%s: variable may not be assigned value" , 5) , name);
0
2532#if 0-
2533 /* Let noassign variables through with a warning */-
2534 if (readonly_p (old_var))-
2535#endif-
2536 return ((SHELL_VAR *)NULL);
executed 2 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
2
2537 }-
2538-
2539 if (old_var == 0)
old_var == 0Description
TRUEevaluated 454 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
82-454
2540 new_var = make_new_variable (name, vc->table);
executed 454 times by 1 test: new_var = make_new_variable (name, vc->table);
Executed by:
  • Self test
454
2541 else-
2542 {-
2543 new_var = make_new_variable (name, vc->table);-
2544-
2545 /* If we found this variable in one of the temporary environments,-
2546 inherit its value. Watch to see if this causes problems with-
2547 things like `x=4 local x'. XXX - see above for temporary env-
2548 variables with the same context level as variable_context */-
2549 /* XXX - we should only do this if the variable is not an array. */-
2550 /* If we want to change the local variable semantics to "inherit-
2551 the old variable's value" here is where to set it. And we would-
2552 need to use copy_variable (currently unused) to do it for all-
2553 possible variable values. */-
2554 if (was_tmpvar)
was_tmpvarDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
3-79
2555 var_setvalue (new_var, savestring (old_value));
executed 3 times by 1 test: ((new_var)->value = ((char *)strcpy (sh_xmalloc((1 + strlen (old_value)), "variables.c", 2555), (old_value))));
Executed by:
  • Self test
3
2556 else if (localvar_inherit || (flags & MKLOC_INHERIT))
localvar_inheritDescription
TRUEnever evaluated
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
(flags & 0x01)Description
TRUEnever evaluated
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
0-79
2557 {-
2558 /* This may not make sense for nameref variables that are shadowing-
2559 variables with the same name, but we don't know that yet. */-
2560#if defined (ARRAY_VARS)-
2561 if (assoc_p (old_var))
((((old_var)->... (0x0000040)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2562 var_setassoc (new_var, assoc_copy (assoc_cell (old_var)));
never executed: ((new_var)->value = (char *)((hash_copy(((HASH_TABLE *)((old_var)->value)), 0))));
0
2563 else if (array_p (old_var))
((((old_var)->... (0x0000004)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2564 var_setarray (new_var, array_copy (array_cell (old_var)));
never executed: ((new_var)->value = (char *)(array_copy ((ARRAY *)((old_var)->value))));
0
2565 else if (value_cell (old_var))
((old_var)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
2566#else-
2567 if (value_cell (old_var))-
2568#endif-
2569 var_setvalue (new_var, savestring (value_cell (old_var)));
never executed: ((new_var)->value = ((char *)strcpy (sh_xmalloc((1 + strlen (((old_var)->value))), "variables.c", 2569), (((old_var)->value)))));
0
2570 else-
2571 var_setvalue (new_var, (char *)NULL);
never executed: ((new_var)->value = ((char *) ((void *)0) ));
0
2572 }-
2573-
2574 if (localvar_inherit || (flags & MKLOC_INHERIT))
localvar_inheritDescription
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
(flags & 0x01)Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
0-82
2575 {-
2576 /* It doesn't make sense to inherit the nameref attribute */-
2577 new_var->attributes = old_var->attributes & ~att_nameref;-
2578 new_var->dynamic_value = old_var->dynamic_value;-
2579 new_var->assign_func = old_var->assign_func;-
2580 }
never executed: end of block
0
2581 else-
2582 /* We inherit the export attribute, but no others. */-
2583 new_var->attributes = exported_p (old_var) ? att_exported : 0;
executed 82 times by 1 test: new_var->attributes = ((((old_var)->attributes) & (0x0000001))) ? 0x0000001 : 0;
Executed by:
  • Self test
((((old_var)->... (0x0000001)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
6-82
2584 }-
2585-
2586 vc->flags |= VC_HASLOCAL;-
2587-
2588 new_var->context = variable_context;-
2589 VSETATTR (new_var, att_local);-
2590-
2591 if (ifsname (name))
(name)[0] == 'I'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 534 times by 1 test
Evaluated by:
  • Self test
(name)[1] == 'F'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(name)[2] == 'S'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(name)[3] == '\0'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-534
2592 setifs (new_var);
executed 2 times by 1 test: setifs (new_var);
Executed by:
  • Self test
2
2593-
2594 /* value_cell will be 0 if localvar_inherit == 0 or there was no old variable-
2595 with the same name or the old variable was invisible */-
2596 if (was_tmpvar == 0 && no_invisible_vars == 0 && value_cell (new_var) == 0)
was_tmpvar == 0Description
TRUEevaluated 533 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
no_invisible_vars == 0Description
TRUEevaluated 533 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((new_var)->value) == 0Description
TRUEevaluated 533 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-533
2597 VSETATTR (new_var, att_invisible); /* XXX */
executed 533 times by 1 test: ((new_var)->attributes |= (0x0001000));
Executed by:
  • Self test
533
2598 return (new_var);
executed 536 times by 1 test: return (new_var);
Executed by:
  • Self test
536
2599}-
2600-
2601/* Create a new shell variable with name NAME. */-
2602static SHELL_VAR *-
2603new_shell_variable (name)-
2604 const char *name;-
2605{-
2606 SHELL_VAR *entry;-
2607-
2608 entry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));-
2609-
2610 entry->name = savestring (name);-
2611 var_setvalue (entry, (char *)NULL);-
2612 CLEAR_EXPORTSTR (entry);-
2613-
2614 entry->dynamic_value = (sh_var_value_func_t *)NULL;-
2615 entry->assign_func = (sh_var_assign_func_t *)NULL;-
2616-
2617 entry->attributes = 0;-
2618-
2619 /* Always assume variables are to be made at toplevel!-
2620 make_local_variable has the responsibility of changing the-
2621 variable context. */-
2622 entry->context = 0;-
2623-
2624 return (entry);
executed 407137 times by 1 test: return (entry);
Executed by:
  • Self test
407137
2625}-
2626-
2627/* Create a new shell variable with name NAME and add it to the hash table-
2628 TABLE. */-
2629static SHELL_VAR *-
2630make_new_variable (name, table)-
2631 const char *name;-
2632 HASH_TABLE *table;-
2633{-
2634 SHELL_VAR *entry;-
2635 BUCKET_CONTENTS *elt;-
2636-
2637 entry = new_shell_variable (name);-
2638-
2639 /* Make sure we have a shell_variables hash table to add to. */-
2640 if (shell_variables == 0)
shell_variables == 0Description
TRUEnever evaluated
FALSEevaluated 397163 times by 1 test
Evaluated by:
  • Self test
0-397163
2641 create_variable_tables ();
never executed: create_variable_tables ();
0
2642-
2643 elt = hash_insert (savestring (name), table, HASH_NOSRCH);-
2644 elt->data = (PTR_T)entry;-
2645-
2646 return entry;
executed 397163 times by 1 test: return entry;
Executed by:
  • Self test
397163
2647}-
2648-
2649#if defined (ARRAY_VARS)-
2650SHELL_VAR *-
2651make_new_array_variable (name)-
2652 char *name;-
2653{-
2654 SHELL_VAR *entry;-
2655 ARRAY *array;-
2656-
2657 entry = make_new_variable (name, global_variables->table);-
2658 array = array_create ();-
2659-
2660 var_setarray (entry, array);-
2661 VSETATTR (entry, att_array);-
2662 return entry;
executed 49519 times by 1 test: return entry;
Executed by:
  • Self test
49519
2663}-
2664-
2665SHELL_VAR *-
2666make_local_array_variable (name, assoc_ok)-
2667 char *name;-
2668 int assoc_ok;-
2669{-
2670 SHELL_VAR *var;-
2671 ARRAY *array;-
2672-
2673 var = make_local_variable (name, 0); /* XXX for now */-
2674 if (var == 0 || array_p (var) || (assoc_ok && assoc_p (var)))
var == 0Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000004)))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
assoc_okDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000040)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-24
2675 return var;
executed 9 times by 1 test: return var;
Executed by:
  • Self test
9
2676-
2677 array = array_create ();-
2678-
2679 dispose_variable_value (var);-
2680 var_setarray (var, array);-
2681 VSETATTR (var, att_array);-
2682 return var;
executed 15 times by 1 test: return var;
Executed by:
  • Self test
15
2683}-
2684-
2685SHELL_VAR *-
2686make_new_assoc_variable (name)-
2687 char *name;-
2688{-
2689 SHELL_VAR *entry;-
2690 HASH_TABLE *hash;-
2691-
2692 entry = make_new_variable (name, global_variables->table);-
2693 hash = assoc_create (0);-
2694-
2695 var_setassoc (entry, hash);-
2696 VSETATTR (entry, att_assoc);-
2697 return entry;
executed 11006 times by 1 test: return entry;
Executed by:
  • Self test
11006
2698}-
2699-
2700SHELL_VAR *-
2701make_local_assoc_variable (name)-
2702 char *name;-
2703{-
2704 SHELL_VAR *var;-
2705 HASH_TABLE *hash;-
2706-
2707 var = make_local_variable (name, 0); /* XXX for now */-
2708 if (var == 0 || assoc_p (var))
var == 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-4
2709 return var;
executed 2 times by 1 test: return var;
Executed by:
  • Self test
2
2710-
2711 dispose_variable_value (var);-
2712 hash = assoc_create (0);-
2713-
2714 var_setassoc (var, hash);-
2715 VSETATTR (var, att_assoc);-
2716 return var;
executed 2 times by 1 test: return var;
Executed by:
  • Self test
2
2717}-
2718#endif-
2719-
2720char *-
2721make_variable_value (var, value, flags)-
2722 SHELL_VAR *var;-
2723 char *value;-
2724 int flags;-
2725{-
2726 char *retval, *oval;-
2727 intmax_t lval, rval;-
2728 int expok, olen, op;-
2729-
2730 /* If this variable has had its type set to integer (via `declare -i'),-
2731 then do expression evaluation on it and store the result. The-
2732 functions in expr.c (evalexp()) and bind_int_variable() are responsible-
2733 for turning off the integer flag if they don't want further-
2734 evaluation done. Callers that find it inconvenient to do this can set-
2735 the ASS_NOEVAL flag. For the special case of arithmetic expression-
2736 evaluation, the caller can set ASS_NOLONGJMP to avoid jumping out to-
2737 top_level. */-
2738 if ((flags & ASS_NOEVAL) == 0 && integer_p (var))
(flags & 0x0100) == 0Description
TRUEevaluated 115381044 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000010)))Description
TRUEevaluated 663 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115380381 times by 1 test
Evaluated by:
  • Self test
0-115381044
2739 {-
2740 if (flags & ASS_APPEND)
flags & 0x0001Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 600 times by 1 test
Evaluated by:
  • Self test
63-600
2741 {-
2742 oval = value_cell (var);-
2743 lval = evalexp (oval, 0, &expok); /* ksh93 seems to do this */-
2744 if (expok == 0)
expok == 0Description
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
0-63
2745 {-
2746 if (flags & ASS_NOLONGJMP)
flags & 0x0200Description
TRUEnever evaluated
FALSEnever evaluated
0
2747 goto make_value;
never executed: goto make_value;
0
2748 else-
2749 {-
2750 top_level_cleanup ();-
2751 jump_to_top_level (DISCARD);-
2752 }
never executed: end of block
0
2753 }-
2754 }
executed 63 times by 1 test: end of block
Executed by:
  • Self test
63
2755 rval = evalexp (value, 0, &expok);-
2756 if (expok == 0)
expok == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 647 times by 1 test
Evaluated by:
  • Self test
16-647
2757 {-
2758 if (flags & ASS_NOLONGJMP)
flags & 0x0200Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
0-16
2759 goto make_value;
never executed: goto make_value;
0
2760 else-
2761 {-
2762 top_level_cleanup ();-
2763 jump_to_top_level (DISCARD);-
2764 }
never executed: end of block
0
2765 }-
2766 /* This can be fooled if the variable's value changes while evaluating-
2767 `rval'. We can change it if we move the evaluation of lval to here. */-
2768 if (flags & ASS_APPEND)
flags & 0x0001Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 584 times by 1 test
Evaluated by:
  • Self test
63-584
2769 rval += lval;
executed 63 times by 1 test: rval += lval;
Executed by:
  • Self test
63
2770 retval = itos (rval);-
2771 }
executed 647 times by 1 test: end of block
Executed by:
  • Self test
647
2772#if defined (CASEMOD_ATTRS)-
2773 else if ((flags & ASS_NOEVAL) == 0 && (capcase_p (var) || uppercase_p (var) || lowercase_p (var)))
(flags & 0x0100) == 0Description
TRUEevaluated 115380381 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000400)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115380379 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000100)))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115380376 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000200)))Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115380363 times by 1 test
Evaluated by:
  • Self test
0-115380381
2774 {-
2775 if (flags & ASS_APPEND)
flags & 0x0001Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
2-16
2776 {-
2777 oval = get_variable_value (var);-
2778 if (oval == 0) /* paranoia */
oval == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
2779 oval = "";
never executed: oval = "";
0
2780 olen = STRLEN (oval);
(oval)[1]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(oval)[2]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(oval)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(oval)[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
2781 retval = (char *)xmalloc (olen + (value ? STRLEN (value) : 0) + 1);-
2782 strcpy (retval, oval);-
2783 if (value)
valueDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
2784 strcpy (retval+olen, value);
executed 2 times by 1 test: strcpy (retval+olen, value);
Executed by:
  • Self test
2
2785 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
2786 else if (*value)
*valueDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-16
2787 retval = savestring (value);
executed 16 times by 1 test: retval = (char *)strcpy (sh_xmalloc((1 + strlen (value)), "variables.c", 2787), (value));
Executed by:
  • Self test
16
2788 else-
2789 {-
2790 retval = (char *)xmalloc (1);-
2791 retval[0] = '\0';-
2792 }
never executed: end of block
0
2793 op = capcase_p (var) ? CASE_CAPITALIZE
((((var)->attr... (0x0000400)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
2-16
2794 : (uppercase_p (var) ? CASE_UPPER : CASE_LOWER);
((((var)->attr... (0x0000100)))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
3-13
2795 oval = sh_modcase (retval, (char *)0, op);-
2796 free (retval);-
2797 retval = oval;-
2798 }
executed 18 times by 1 test: end of block
Executed by:
  • Self test
18
2799#endif /* CASEMOD_ATTRS */-
2800 else if (value)
valueDescription
TRUEevaluated 115320054 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60309 times by 1 test
Evaluated by:
  • Self test
60309-115320054
2801 {-
2802make_value:-
2803 if (flags & ASS_APPEND)
flags & 0x0001Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115320033 times by 1 test
Evaluated by:
  • Self test
21-115320033
2804 {-
2805 oval = get_variable_value (var);-
2806 if (oval == 0) /* paranoia */
oval == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
1-20
2807 oval = "";
executed 1 time by 1 test: oval = "";
Executed by:
  • Self test
1
2808 olen = STRLEN (oval);
(oval)[1]Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(oval)[2]Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(oval)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(oval)[0]Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-21
2809 retval = (char *)xmalloc (olen + (value ? STRLEN (value) : 0) + 1);-
2810 strcpy (retval, oval);-
2811 if (value)
valueDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-21
2812 strcpy (retval+olen, value);
executed 21 times by 1 test: strcpy (retval+olen, value);
Executed by:
  • Self test
21
2813 }
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
2814 else if (*value)
*valueDescription
TRUEevaluated 79786439 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35533594 times by 1 test
Evaluated by:
  • Self test
35533594-79786439
2815 retval = savestring (value);
executed 79786439 times by 1 test: retval = (char *)strcpy (sh_xmalloc((1 + strlen (value)), "variables.c", 2815), (value));
Executed by:
  • Self test
79786439
2816 else-
2817 {-
2818 retval = (char *)xmalloc (1);-
2819 retval[0] = '\0';-
2820 }
executed 35533594 times by 1 test: end of block
Executed by:
  • Self test
35533594
2821 }-
2822 else-
2823 retval = (char *)NULL;
executed 60309 times by 1 test: retval = (char *) ((void *)0) ;
Executed by:
  • Self test
60309
2824-
2825 return retval;
executed 115381028 times by 1 test: return retval;
Executed by:
  • Self test
115381028
2826}-
2827-
2828/* If we can optimize appending to string variables, say so */-
2829static int-
2830can_optimize_assignment (entry, value, aflags)-
2831 SHELL_VAR *entry;-
2832 char *value;-
2833 int aflags;-
2834{-
2835 if ((aflags & ASS_APPEND) == 0)
(aflags & 0x0001) == 0Description
TRUEevaluated 115031823 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
64-115031823
2836 return 0;
executed 115031823 times by 1 test: return 0;
Executed by:
  • Self test
115031823
2837#if defined (ARRAY_VARS)-
2838 if (array_p (entry) || assoc_p (entry))
((((entry)->at... (0x0000004)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000040)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62 times by 1 test
Evaluated by:
  • Self test
1-63
2839 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • Self test
2
2840#endif-
2841 if (integer_p (entry) || uppercase_p (entry) || lowercase_p (entry) || capcase_p (entry))
((((entry)->at... (0x0000010)))Description
TRUEevaluated 55 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000100)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000200)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000400)))Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-55
2842 return 0;
executed 57 times by 1 test: return 0;
Executed by:
  • Self test
57
2843 if (readonly_p (entry) || noassign_p (entry))
((((entry)->at... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
2844 return 0;
never executed: return 0;
0
2845 return 1;
executed 5 times by 1 test: return 1;
Executed by:
  • Self test
5
2846}-
2847-
2848/* right now we optimize appends to string variables */-
2849static SHELL_VAR *-
2850optimized_assignment (entry, value, aflags)-
2851 SHELL_VAR *entry;-
2852 char *value;-
2853 int aflags;-
2854{-
2855 size_t len, vlen;-
2856 char *v, *new;-
2857-
2858 v = value_cell (entry);-
2859 len = STRLEN (v);
(v)[1]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(v)[2]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(v)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(v)[0]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-5
2860 vlen = STRLEN (value);
(value)[1]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(value)[2]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[0]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5
2861-
2862 new = (char *)xrealloc (v, len + vlen + 8); /* for now */-
2863 if (vlen == 1)
vlen == 1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-4
2864 {-
2865 new[len] = *value;-
2866 new[len+1] = '\0';-
2867 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
2868 else-
2869 strcpy (new + len, value);
executed 1 time by 1 test: strcpy (new + len, value);
Executed by:
  • Self test
1
2870 var_setvalue (entry, new);-
2871 return entry;
executed 5 times by 1 test: return entry;
Executed by:
  • Self test
5
2872}-
2873-
2874/* Bind a variable NAME to VALUE in the HASH_TABLE TABLE, which may be the-
2875 temporary environment (but usually is not). HFLAGS controls how NAME-
2876 is looked up in TABLE; AFLAGS controls how VALUE is assigned */-
2877static SHELL_VAR *-
2878bind_variable_internal (name, value, table, hflags, aflags)-
2879 const char *name;-
2880 char *value;-
2881 HASH_TABLE *table;-
2882 int hflags, aflags;-
2883{-
2884 char *newval, *tname;-
2885 SHELL_VAR *entry, *tentry;-
2886-
2887 entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
(hflags & 0x01)Description
TRUEevaluated 32850 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115333419 times by 1 test
Evaluated by:
  • Self test
32850-115333419
2888 /* Follow the nameref chain here if this is the global variables table */-
2889 if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
entryDescription
TRUEevaluated 115031997 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334272 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000800)))Description
TRUEevaluated 101 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031896 times by 1 test
Evaluated by:
  • Self test
(((((entry)->a...01000))) == 0)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
table == globa...riables->tableDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-115031997
2890 {-
2891 entry = find_global_variable (entry->name);-
2892 /* Let's see if we have a nameref referencing a variable that hasn't yet-
2893 been created. */-
2894 if (entry == 0)
entry == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
8-13
2895 entry = find_variable_last_nameref (name, 0); /* XXX */
executed 13 times by 1 test: entry = find_variable_last_nameref (name, 0);
Executed by:
  • Self test
13
2896 if (entry == 0) /* just in case */
entry == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
2-19
2897 return (entry);
executed 2 times by 1 test: return (entry);
Executed by:
  • Self test
2
2898 }
executed 19 times by 1 test: end of block
Executed by:
  • Self test
19
2899-
2900 /* The first clause handles `declare -n ref; ref=x;' or `declare -n ref;-
2901 declare -n ref' */-
2902 if (entry && invisible_p (entry) && nameref_p (entry))
entryDescription
TRUEevaluated 115031995 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334272 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0001000)))Description
TRUEevaluated 346 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031649 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000800)))Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 266 times by 1 test
Evaluated by:
  • Self test
80-115031995
2903 {-
2904 if ((aflags & ASS_FORCE) == 0 && value && valid_nameref_value (value, 0) == 0)
(aflags & 0x0020) == 0Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
valueDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
valid_nameref_...value, 0) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-66
2905 {-
2906 sh_invalidid (value);-
2907 return ((SHELL_VAR *)NULL);
executed 57 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
57
2908 }-
2909 goto assign_value;
executed 23 times by 1 test: goto assign_value;
Executed by:
  • Self test
23
2910 }-
2911 else if (entry && nameref_p (entry))
entryDescription
TRUEevaluated 115031915 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334272 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000800)))Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031904 times by 1 test
Evaluated by:
  • Self test
11-115031915
2912 {-
2913 newval = nameref_cell (entry);-
2914#if defined (ARRAY_VARS)-
2915 /* declare -n foo=x[2] ; foo=bar */-
2916 if (valid_array_reference (newval, 0))
valid_array_re...ce (newval, 0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
5-6
2917 {-
2918 tname = array_variable_name (newval, 0, (char **)0, (int *)0);-
2919 if (tname && (tentry = find_variable_noref (tname)) && nameref_p (tentry))
tnameDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tentry = find...noref (tname))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
((((tentry)->a... (0x0000800)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-5
2920 {-
2921 /* nameref variables can't be arrays */-
2922 internal_warning (_("%s: removing nameref attribute"), name_cell (tentry));-
2923 FREE (value_cell (tentry)); /* XXX - bash-4.3 compat */
executed 1 time by 1 test: sh_xfree((((tentry)->value)), "variables.c", 2923);
Executed by:
  • Self test
((tentry)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
2924 var_setvalue (tentry, (char *)NULL);-
2925 VUNSETATTR (tentry, att_nameref);-
2926 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
2927 free (tname);-
2928 /* XXX - should it be aflags? */-
2929 entry = assign_array_element (newval, make_variable_value (entry, value, aflags), aflags|ASS_NAMEREF);-
2930 if (entry == 0)
entry == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
2931 return entry;
executed 2 times by 1 test: return entry;
Executed by:
  • Self test
2
2932 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
2933 else-
2934#endif-
2935 {-
2936 entry = make_new_variable (newval, table);-
2937 var_setvalue (entry, make_variable_value (entry, value, aflags));-
2938 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
2939 }-
2940 else if (entry == 0)
entry == 0Description
TRUEevaluated 334272 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031904 times by 1 test
Evaluated by:
  • Self test
334272-115031904
2941 {-
2942 entry = make_new_variable (name, table);-
2943 var_setvalue (entry, make_variable_value (entry, value, aflags)); /* XXX */-
2944 }
executed 334272 times by 1 test: end of block
Executed by:
  • Self test
334272
2945 else if (entry->assign_func) /* array vars have assign functions now */
entry->assign_funcDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031894 times by 1 test
Evaluated by:
  • Self test
10-115031894
2946 {-
2947 INVALIDATE_EXPORTSTR (entry);
never executed: end of block
(entry)->exportstrDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
2948 newval = (aflags & ASS_APPEND) ? make_variable_value (entry, value, aflags) : value;
(aflags & 0x0001)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
2949 if (assoc_p (entry))
((((entry)->at... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
2950 entry = (*(entry->assign_func)) (entry, newval, -1, savestring ("0"));
never executed: entry = (*(entry->assign_func)) (entry, newval, -1, (char *)strcpy (sh_xmalloc((1 + strlen ("0")), "variables.c", 2950), ("0")));
0
2951 else if (array_p (entry))
((((entry)->at... (0x0000004)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
4-6
2952 entry = (*(entry->assign_func)) (entry, newval, 0, 0);
executed 4 times by 1 test: entry = (*(entry->assign_func)) (entry, newval, 0, 0);
Executed by:
  • Self test
4
2953 else-
2954 entry = (*(entry->assign_func)) (entry, newval, -1, 0);
executed 6 times by 1 test: entry = (*(entry->assign_func)) (entry, newval, -1, 0);
Executed by:
  • Self test
6
2955 if (newval != value)
newval != valueDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
2956 free (newval);
never executed: sh_xfree((newval), "variables.c", 2956);
0
2957 return (entry);
executed 10 times by 1 test: return (entry);
Executed by:
  • Self test
10
2958 }-
2959 else-
2960 {-
2961assign_value:-
2962 if ((readonly_p (entry) && (aflags & ASS_FORCE) == 0) || noassign_p (entry))
((((entry)->at... (0x0000002)))Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031882 times by 1 test
Evaluated by:
  • Self test
(aflags & 0x0020) == 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 115031887 times by 1 test
Evaluated by:
  • Self test
0-115031887
2963 {-
2964 if (readonly_p (entry))
((((entry)->at... (0x0000002)))Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-30
2965 err_readonly (name_cell (entry));
executed 30 times by 1 test: err_readonly (((entry)->name));
Executed by:
  • Self test
30
2966 return (entry);
executed 30 times by 1 test: return (entry);
Executed by:
  • Self test
30
2967 }-
2968-
2969 /* Variables which are bound are visible. */-
2970 VUNSETATTR (entry, att_invisible);-
2971-
2972 /* If we can optimize the assignment, do so and return. Right now, we-
2973 optimize appends to string variables. */-
2974 if (can_optimize_assignment (entry, value, aflags))
can_optimize_a...value, aflags)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031882 times by 1 test
Evaluated by:
  • Self test
5-115031882
2975 {-
2976 INVALIDATE_EXPORTSTR (entry);
never executed: end of block
(entry)->exportstrDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
2977 optimized_assignment (entry, value, aflags);-
2978-
2979 if (mark_modified_vars)
mark_modified_varsDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
2980 VSETATTR (entry, att_exported);
never executed: ((entry)->attributes |= (0x0000001));
0
2981-
2982 if (exported_p (entry))
((((entry)->at... (0x0000001)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
1-4
2983 array_needs_making = 1;
executed 1 time by 1 test: array_needs_making = 1;
Executed by:
  • Self test
1
2984-
2985 return (entry);
executed 5 times by 1 test: return (entry);
Executed by:
  • Self test
5
2986 }-
2987-
2988#if defined (ARRAY_VARS)-
2989 if (assoc_p (entry) || array_p (entry))
((((entry)->at... (0x0000040)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031877 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000004)))Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031852 times by 1 test
Evaluated by:
  • Self test
5-115031877
2990 newval = make_array_variable_value (entry, 0, "0", value, aflags);
executed 30 times by 1 test: newval = make_array_variable_value (entry, 0, "0", value, aflags);
Executed by:
  • Self test
30
2991 else-
2992#endif-
2993 newval = make_variable_value (entry, value, aflags); /* XXX */
executed 115031852 times by 1 test: newval = make_variable_value (entry, value, aflags);
Executed by:
  • Self test
115031852
2994-
2995 /* Invalidate any cached export string */-
2996 INVALIDATE_EXPORTSTR (entry);
executed 11133 times by 1 test: end of block
Executed by:
  • Self test
(entry)->exportstrDescription
TRUEevaluated 11133 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115020733 times by 1 test
Evaluated by:
  • Self test
11133-115020733
2997-
2998#if defined (ARRAY_VARS)-
2999 /* XXX -- this bears looking at again -- XXX */-
3000 /* If an existing array variable x is being assigned to with x=b or-
3001 `read x' or something of that nature, silently convert it to-
3002 x[0]=b or `read x[0]'. */-
3003 if (assoc_p (entry))
((((entry)->at... (0x0000040)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031861 times by 1 test
Evaluated by:
  • Self test
5-115031861
3004 {-
3005 assoc_insert (assoc_cell (entry), savestring ("0"), newval);-
3006 free (newval);-
3007 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
3008 else if (array_p (entry))
((((entry)->at... (0x0000004)))Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115031836 times by 1 test
Evaluated by:
  • Self test
25-115031836
3009 {-
3010 array_insert (array_cell (entry), 0, newval);-
3011 free (newval);-
3012 }
executed 25 times by 1 test: end of block
Executed by:
  • Self test
25
3013 else-
3014#endif-
3015 {-
3016 FREE (value_cell (entry));
executed 115031548 times by 1 test: sh_xfree((((entry)->value)), "variables.c", 3016);
Executed by:
  • Self test
((entry)->value)Description
TRUEevaluated 115031548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 288 times by 1 test
Evaluated by:
  • Self test
288-115031548
3017 var_setvalue (entry, newval);-
3018 }
executed 115031836 times by 1 test: end of block
Executed by:
  • Self test
115031836
3019 }-
3020-
3021 if (mark_modified_vars)
mark_modified_varsDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115366125 times by 1 test
Evaluated by:
  • Self test
22-115366125
3022 VSETATTR (entry, att_exported);
executed 22 times by 1 test: ((entry)->attributes |= (0x0000001));
Executed by:
  • Self test
22
3023-
3024 if (exported_p (entry))
((((entry)->at... (0x0000001)))Description
TRUEevaluated 11305 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115354842 times by 1 test
Evaluated by:
  • Self test
11305-115354842
3025 array_needs_making = 1;
executed 11305 times by 1 test: array_needs_making = 1;
Executed by:
  • Self test
11305
3026-
3027 return (entry);
executed 115366147 times by 1 test: return (entry);
Executed by:
  • Self test
115366147
3028}-
3029 -
3030/* Bind a variable NAME to VALUE. This conses up the name-
3031 and value strings. If we have a temporary environment, we bind there-
3032 first, then we bind into shell_variables. */-
3033-
3034SHELL_VAR *-
3035bind_variable (name, value, flags)-
3036 const char *name;-
3037 char *value;-
3038 int flags;-
3039{-
3040 SHELL_VAR *v, *nv;-
3041 VAR_CONTEXT *vc, *nvc;-
3042-
3043 if (shell_variables == 0)
shell_variables == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115333347 times by 1 test
Evaluated by:
  • Self test
17-115333347
3044 create_variable_tables ();
executed 17 times by 1 test: create_variable_tables ();
Executed by:
  • Self test
17
3045-
3046 /* If we have a temporary environment, look there first for the variable,-
3047 and, if found, modify the value there before modifying it in the-
3048 shell_variables table. This allows sourced scripts to modify values-
3049 given to them in a temporary environment while modifying the variable-
3050 value that the caller sees. */-
3051 if (temporary_env && value) /* XXX - can value be null here? */
temporary_envDescription
TRUEevaluated 2972 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115330392 times by 1 test
Evaluated by:
  • Self test
valueDescription
TRUEevaluated 2972 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-115330392
3052 bind_tempenv_variable (name, value);
executed 2972 times by 1 test: bind_tempenv_variable (name, value);
Executed by:
  • Self test
2972
3053-
3054 /* XXX -- handle local variables here. */-
3055 for (vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEevaluated 219463146 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115329745 times by 1 test
Evaluated by:
  • Self test
115329745-219463146
3056 {-
3057 if (vc_isfuncenv (vc) || vc_isbltnenv (vc))
(((vc)->flags & 0x04) != 0)Description
TRUEevaluated 104133249 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115329897 times by 1 test
Evaluated by:
  • Self test
(((vc)->flags & 0x08) != 0)Description
TRUEevaluated 152 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115329745 times by 1 test
Evaluated by:
  • Self test
152-115329897
3058 {-
3059 v = hash_lookup (name, vc->table);-
3060 nvc = vc;-
3061 if (v && nameref_p (v))
vDescription
TRUEevaluated 3625 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 104129776 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3605 times by 1 test
Evaluated by:
  • Self test
20-104129776
3062 {-
3063 nv = find_variable_nameref_context (v, vc, &nvc);-
3064 if (nv == 0)
nv == 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
9-11
3065 {-
3066 nv = find_variable_last_nameref_context (v, vc, &nvc);-
3067 if (nv && nameref_p (nv))
nvDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((nv)->attri... (0x0000800)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9
3068 {-
3069 /* If this nameref variable doesn't have a value yet,-
3070 set the value. Otherwise, assign using the value as-
3071 normal. */-
3072 if (nameref_cell (nv) == 0)
((nv)->value) == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
4-5
3073 return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
executed 4 times by 1 test: return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
Executed by:
  • Self test
4
3074#if defined (ARRAY_VARS)-
3075 else if (valid_array_reference (nameref_cell (nv), 0))
valid_array_re...v)->value), 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-3
3076 return (assign_array_element (nameref_cell (nv), value, flags));
executed 3 times by 1 test: return (assign_array_element (((nv)->value), value, flags));
Executed by:
  • Self test
3
3077 else-
3078#endif-
3079 return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags));
executed 2 times by 1 test: return (bind_variable_internal (((nv)->value), value, nvc->table, 0, flags));
Executed by:
  • Self test
2
3080 }-
3081 else if (nv == &nameref_maxloop_value)
nv == &nameref_maxloop_valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
3082 {-
3083 internal_warning (_("%s: circular name reference"), v->name);-
3084#if 0-
3085 return (bind_variable_value (v, value, flags|ASS_NAMEREF));-
3086#else-
3087 v = 0; /* backwards compat */-
3088#endif-
3089 }
never executed: end of block
0
3090 else-
3091 v = nv;
never executed: v = nv;
0
3092 }-
3093 else if (nv == &nameref_maxloop_value)
nv == &nameref_maxloop_valueDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
5-6
3094 {-
3095 internal_warning (_("%s: circular name reference"), v->name);-
3096#if 0-
3097 return (bind_variable_value (v, value, flags|ASS_NAMEREF));-
3098#else-
3099 v = 0; /* backwards compat */-
3100#endif-
3101 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
3102 else-
3103 v = nv;
executed 5 times by 1 test: v = nv;
Executed by:
  • Self test
5
3104 }-
3105 if (v)
vDescription
TRUEevaluated 3610 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 104129782 times by 1 test
Evaluated by:
  • Self test
3610-104129782
3106 return (bind_variable_internal (v->name, value, nvc->table, 0, flags));
executed 3610 times by 1 test: return (bind_variable_internal (v->name, value, nvc->table, 0, flags));
Executed by:
  • Self test
3610
3107 }
executed 104129782 times by 1 test: end of block
Executed by:
  • Self test
104129782
3108 }
executed 219459527 times by 1 test: end of block
Executed by:
  • Self test
219459527
3109 /* bind_variable_internal will handle nameref resolution in this case */-
3110 return (bind_variable_internal (name, value, global_variables->table, 0, flags));
executed 115329745 times by 1 test: return (bind_variable_internal (name, value, global_variables->table, 0, flags));
Executed by:
  • Self test
115329745
3111}-
3112-
3113SHELL_VAR *-
3114bind_global_variable (name, value, flags)-
3115 const char *name;-
3116 char *value;-
3117 int flags;-
3118{-
3119 if (shell_variables == 0)
shell_variables == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-7
3120 create_variable_tables ();
never executed: create_variable_tables ();
0
3121-
3122 /* bind_variable_internal will handle nameref resolution in this case */-
3123 return (bind_variable_internal (name, value, global_variables->table, 0, flags));
executed 7 times by 1 test: return (bind_variable_internal (name, value, global_variables->table, 0, flags));
Executed by:
  • Self test
7
3124}-
3125-
3126/* Make VAR, a simple shell variable, have value VALUE. Once assigned a-
3127 value, variables are no longer invisible. This is a duplicate of part-
3128 of the internals of bind_variable. If the variable is exported, or-
3129 all modified variables should be exported, mark the variable for export-
3130 and note that the export environment needs to be recreated. */-
3131SHELL_VAR *-
3132bind_variable_value (var, value, aflags)-
3133 SHELL_VAR *var;-
3134 char *value;-
3135 int aflags;-
3136{-
3137 char *t;-
3138 int invis;-
3139-
3140 invis = invisible_p (var);-
3141 VUNSETATTR (var, att_invisible);-
3142-
3143 if (var->assign_func)
var->assign_funcDescription
TRUEnever evaluated
FALSEevaluated 670 times by 1 test
Evaluated by:
  • Self test
0-670
3144 {-
3145 /* If we're appending, we need the old value, so use-
3146 make_variable_value */-
3147 t = (aflags & ASS_APPEND) ? make_variable_value (var, value, aflags) : value;
(aflags & 0x0001)Description
TRUEnever evaluated
FALSEnever evaluated
0
3148 (*(var->assign_func)) (var, t, -1, 0);-
3149 if (t != value && t)
t != valueDescription
TRUEnever evaluated
FALSEnever evaluated
tDescription
TRUEnever evaluated
FALSEnever evaluated
0
3150 free (t);
never executed: sh_xfree((t), "variables.c", 3150);
0
3151 }
never executed: end of block
0
3152 else-
3153 {-
3154 t = make_variable_value (var, value, aflags);-
3155 if ((aflags & (ASS_NAMEREF|ASS_FORCE)) == ASS_NAMEREF && check_selfref (name_cell (var), t, 0))
(aflags & (0x0...20)) == 0x0010Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 485 times by 1 test
Evaluated by:
  • Self test
check_selfref ...->name), t, 0)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 176 times by 1 test
Evaluated by:
  • Self test
9-485
3156 {-
3157 if (variable_context)
variable_contextDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-8
3158 internal_warning (_("%s: circular name reference"), name_cell (var));
executed 8 times by 1 test: internal_warning ( dcgettext (((void *)0), "%s: circular name reference" , 5) , ((var)->name));
Executed by:
  • Self test
8
3159 else-
3160 {-
3161 internal_error (_("%s: nameref variable self references not allowed"), name_cell (var));-
3162 free (t);-
3163 if (invis)
invisDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
3164 VSETATTR (var, att_invisible); /* XXX */
never executed: ((var)->attributes |= (0x0001000));
0
3165 return ((SHELL_VAR *)NULL);
executed 1 time by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
1
3166 }-
3167 }-
3168 if ((aflags & ASS_NAMEREF) && (valid_nameref_value (t, 0) == 0))
(aflags & 0x0010)Description
TRUEevaluated 184 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 485 times by 1 test
Evaluated by:
  • Self test
(valid_nameref...e (t, 0) == 0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 171 times by 1 test
Evaluated by:
  • Self test
13-485
3169 {-
3170 free (t);-
3171 if (invis)
invisDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
5-8
3172 VSETATTR (var, att_invisible); /* XXX */
executed 5 times by 1 test: ((var)->attributes |= (0x0001000));
Executed by:
  • Self test
5
3173 return ((SHELL_VAR *)NULL);
executed 13 times by 1 test: return ((SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
13
3174 }-
3175 FREE (value_cell (var));
executed 208 times by 1 test: sh_xfree((((var)->value)), "variables.c", 3175);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 208 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 448 times by 1 test
Evaluated by:
  • Self test
208-448
3176 var_setvalue (var, t);-
3177 }
executed 656 times by 1 test: end of block
Executed by:
  • Self test
656
3178-
3179 INVALIDATE_EXPORTSTR (var);
executed 4 times by 1 test: end of block
Executed by:
  • Self test
(var)->exportstrDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 652 times by 1 test
Evaluated by:
  • Self test
4-652
3180-
3181 if (mark_modified_vars)
mark_modified_varsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 654 times by 1 test
Evaluated by:
  • Self test
2-654
3182 VSETATTR (var, att_exported);
executed 2 times by 1 test: ((var)->attributes |= (0x0000001));
Executed by:
  • Self test
2
3183-
3184 if (exported_p (var))
((((var)->attr... (0x0000001)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 647 times by 1 test
Evaluated by:
  • Self test
9-647
3185 array_needs_making = 1;
executed 9 times by 1 test: array_needs_making = 1;
Executed by:
  • Self test
9
3186-
3187 return (var);
executed 656 times by 1 test: return (var);
Executed by:
  • Self test
656
3188}-
3189-
3190/* Bind/create a shell variable with the name LHS to the RHS.-
3191 This creates or modifies a variable such that it is an integer.-
3192-
3193 This used to be in expr.c, but it is here so that all of the-
3194 variable binding stuff is localized. Since we don't want any-
3195 recursive evaluation from bind_variable() (possible without this code,-
3196 since bind_variable() calls the evaluator for variables with the integer-
3197 attribute set), we temporarily turn off the integer attribute for each-
3198 variable we set here, then turn it back on after binding as necessary. */-
3199-
3200SHELL_VAR *-
3201bind_int_variable (lhs, rhs, flags)-
3202 char *lhs, *rhs;-
3203 int flags;-
3204{-
3205 register SHELL_VAR *v;-
3206 int isint, isarr, implicitarray;-
3207-
3208 isint = isarr = implicitarray = 0;-
3209#if defined (ARRAY_VARS)-
3210 if (valid_array_reference (lhs, (flags & ASS_NOEXPAND) != 0))
valid_array_re... 0x0080) != 0)Description
TRUEevaluated 10045 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7173330 times by 1 test
Evaluated by:
  • Self test
10045-7173330
3211 {-
3212 isarr = 1;-
3213 v = array_variable_part (lhs, (flags & ASS_NOEXPAND) != 0, (char **)0, (int *)0);-
3214 }
executed 10045 times by 1 test: end of block
Executed by:
  • Self test
10045
3215 else-
3216#endif-
3217 v = find_variable (lhs);
executed 7173330 times by 1 test: v = find_variable (lhs);
Executed by:
  • Self test
7173330
3218-
3219 if (v)
vDescription
TRUEevaluated 7182659 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 716 times by 1 test
Evaluated by:
  • Self test
716-7182659
3220 {-
3221 isint = integer_p (v);-
3222 VUNSETATTR (v, att_integer);-
3223#if defined (ARRAY_VARS)-
3224 if (array_p (v) && isarr == 0)
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 10038 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7172621 times by 1 test
Evaluated by:
  • Self test
isarr == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10031 times by 1 test
Evaluated by:
  • Self test
7-7172621
3225 implicitarray = 1;
executed 7 times by 1 test: implicitarray = 1;
Executed by:
  • Self test
7
3226#endif-
3227 }
executed 7182659 times by 1 test: end of block
Executed by:
  • Self test
7182659
3228-
3229#if defined (ARRAY_VARS)-
3230 if (isarr)
isarrDescription
TRUEevaluated 10045 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7173330 times by 1 test
Evaluated by:
  • Self test
10045-7173330
3231 v = assign_array_element (lhs, rhs, flags);
executed 10045 times by 1 test: v = assign_array_element (lhs, rhs, flags);
Executed by:
  • Self test
10045
3232 else if (implicitarray)
implicitarrayDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7173323 times by 1 test
Evaluated by:
  • Self test
7-7173323
3233 v = bind_array_variable (lhs, 0, rhs, 0); /* XXX - check on flags */
executed 7 times by 1 test: v = bind_array_variable (lhs, 0, rhs, 0);
Executed by:
  • Self test
7
3234 else-
3235#endif-
3236 v = bind_variable (lhs, rhs, 0); /* why not use bind_variable_value? */
executed 7173323 times by 1 test: v = bind_variable (lhs, rhs, 0);
Executed by:
  • Self test
7173323
3237-
3238 if (v)
vDescription
TRUEevaluated 7183362 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-7183362
3239 {-
3240 if (isint)
isintDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7183154 times by 1 test
Evaluated by:
  • Self test
208-7183154
3241 VSETATTR (v, att_integer);
executed 208 times by 1 test: ((v)->attributes |= (0x0000010));
Executed by:
  • Self test
208
3242 VUNSETATTR (v, att_invisible);-
3243 }
executed 7183362 times by 1 test: end of block
Executed by:
  • Self test
7183362
3244-
3245 if (v && nameref_p (v))
vDescription
TRUEevaluated 7183362 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEnever evaluated
FALSEevaluated 7183362 times by 1 test
Evaluated by:
  • Self test
0-7183362
3246 internal_warning (_("%s: assigning integer to name reference"), lhs);
never executed: internal_warning ( dcgettext (((void *)0), "%s: assigning integer to name reference" , 5) , lhs);
0
3247 -
3248 return (v);
executed 7183374 times by 1 test: return (v);
Executed by:
  • Self test
7183374
3249}-
3250-
3251SHELL_VAR *-
3252bind_var_to_int (var, val)-
3253 char *var;-
3254 intmax_t val;-
3255{-
3256 char ibuf[INT_STRLEN_BOUND (intmax_t) + 1], *p;-
3257-
3258 p = fmtulong (val, 10, ibuf, sizeof (ibuf), 0);-
3259 return (bind_int_variable (var, p, 0));
executed 27 times by 1 test: return (bind_int_variable (var, p, 0));
Executed by:
  • Self test
27
3260}-
3261-
3262/* Do a function binding to a variable. You pass the name and-
3263 the command to bind to. This conses the name and command. */-
3264SHELL_VAR *-
3265bind_function (name, value)-
3266 const char *name;-
3267 COMMAND *value;-
3268{-
3269 SHELL_VAR *entry;-
3270-
3271 entry = find_function (name);-
3272 if (entry == 0)
entry == 0Description
TRUEevaluated 9974 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1180 times by 1 test
Evaluated by:
  • Self test
1180-9974
3273 {-
3274 BUCKET_CONTENTS *elt;-
3275-
3276 elt = hash_insert (savestring (name), shell_functions, HASH_NOSRCH);-
3277 entry = new_shell_variable (name);-
3278 elt->data = (PTR_T)entry;-
3279 }
executed 9974 times by 1 test: end of block
Executed by:
  • Self test
9974
3280 else-
3281 INVALIDATE_EXPORTSTR (entry);
never executed: end of block
executed 1180 times by 1 test: end of block
Executed by:
  • Self test
(entry)->exportstrDescription
TRUEnever evaluated
FALSEevaluated 1180 times by 1 test
Evaluated by:
  • Self test
0-1180
3282-
3283 if (var_isset (entry))
((entry)->value != 0)Description
TRUEevaluated 1180 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9974 times by 1 test
Evaluated by:
  • Self test
1180-9974
3284 dispose_command (function_cell (entry));
executed 1180 times by 1 test: dispose_command ((COMMAND *)((entry)->value));
Executed by:
  • Self test
1180
3285-
3286 if (value)
valueDescription
TRUEevaluated 11154 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11154
3287 var_setfunc (entry, copy_command (value));
executed 11154 times by 1 test: ((entry)->value = (char *)(copy_command (value)));
Executed by:
  • Self test
11154
3288 else-
3289 var_setfunc (entry, 0);
never executed: ((entry)->value = (char *)(0));
0
3290-
3291 VSETATTR (entry, att_function);-
3292-
3293 if (mark_modified_vars)
mark_modified_varsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11153 times by 1 test
Evaluated by:
  • Self test
1-11153
3294 VSETATTR (entry, att_exported);
executed 1 time by 1 test: ((entry)->attributes |= (0x0000001));
Executed by:
  • Self test
1
3295-
3296 VUNSETATTR (entry, att_invisible); /* Just to be sure */-
3297-
3298 if (exported_p (entry))
((((entry)->at... (0x0000001)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11153 times by 1 test
Evaluated by:
  • Self test
1-11153
3299 array_needs_making = 1;
executed 1 time by 1 test: array_needs_making = 1;
Executed by:
  • Self test
1
3300-
3301#if defined (PROGRAMMABLE_COMPLETION)-
3302 set_itemlist_dirty (&it_functions);-
3303#endif-
3304-
3305 return (entry);
executed 11154 times by 1 test: return (entry);
Executed by:
  • Self test
11154
3306}-
3307-
3308#if defined (DEBUGGER)-
3309/* Bind a function definition, which includes source file and line number-
3310 information in addition to the command, into the FUNCTION_DEF hash table.-
3311 If (FLAGS & 1), overwrite any existing definition. If FLAGS == 0, leave-
3312 any existing definition alone. */-
3313void-
3314bind_function_def (name, value, flags)-
3315 const char *name;-
3316 FUNCTION_DEF *value;-
3317 int flags;-
3318{-
3319 FUNCTION_DEF *entry;-
3320 BUCKET_CONTENTS *elt;-
3321 COMMAND *cmd;-
3322-
3323 entry = find_function_def (name);-
3324 if (entry && (flags & 1))
entryDescription
TRUEevaluated 12446 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9919 times by 1 test
Evaluated by:
  • Self test
(flags & 1)Description
TRUEevaluated 11154 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1292 times by 1 test
Evaluated by:
  • Self test
1292-12446
3325 {-
3326 dispose_function_def_contents (entry);-
3327 entry = copy_function_def_contents (value, entry);-
3328 }
executed 11154 times by 1 test: end of block
Executed by:
  • Self test
11154
3329 else if (entry)
entryDescription
TRUEevaluated 1292 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9919 times by 1 test
Evaluated by:
  • Self test
1292-9919
3330 return;
executed 1292 times by 1 test: return;
Executed by:
  • Self test
1292
3331 else-
3332 {-
3333 cmd = value->command;-
3334 value->command = 0;-
3335 entry = copy_function_def (value);-
3336 value->command = cmd;-
3337-
3338 elt = hash_insert (savestring (name), shell_function_defs, HASH_NOSRCH);-
3339 elt->data = (PTR_T *)entry;-
3340 }
executed 9919 times by 1 test: end of block
Executed by:
  • Self test
9919
3341}-
3342#endif /* DEBUGGER */-
3343-
3344/* Add STRING, which is of the form foo=bar, to the temporary environment-
3345 HASH_TABLE (temporary_env). The functions in execute_cmd.c are-
3346 responsible for moving the main temporary env to one of the other-
3347 temporary environments. The expansion code in subst.c calls this. */-
3348int-
3349assign_in_env (word, flags)-
3350 WORD_DESC *word;-
3351 int flags;-
3352{-
3353 int offset, aflags;-
3354 char *name, *temp, *value, *newname;-
3355 SHELL_VAR *var;-
3356 const char *string;-
3357-
3358 string = word->word;-
3359-
3360 aflags = 0;-
3361 offset = assignment (string, 0);-
3362 newname = name = savestring (string);-
3363 value = (char *)NULL;-
3364-
3365 if (name[offset] == '=')
name[offset] == '='Description
TRUEevaluated 1844 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1844
3366 {-
3367 name[offset] = 0;-
3368-
3369 /* don't ignore the `+' when assigning temporary environment */-
3370 if (name[offset - 1] == '+')
name[offset - 1] == '+'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1833 times by 1 test
Evaluated by:
  • Self test
11-1833
3371 {-
3372 name[offset - 1] = '\0';-
3373 aflags |= ASS_APPEND;-
3374 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
3375-
3376 var = find_variable (name);-
3377 if (var == 0)
var == 0Description
TRUEevaluated 1531 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 313 times by 1 test
Evaluated by:
  • Self test
313-1531
3378 {-
3379 var = find_variable_last_nameref (name, 1);-
3380 /* If we're assigning a value to a nameref variable in the temp-
3381 environment, and the value of the nameref is valid for assignment,-
3382 but the variable does not already exist, assign to the nameref-
3383 target and add the target to the temporary environment. This is-
3384 what ksh93 does */-
3385 if (var && nameref_p (var) && valid_nameref_value (nameref_cell (var), 1))
varDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1522 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000800)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
valid_nameref_...r)->value), 1)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-1522
3386 {-
3387 newname = nameref_cell (var);-
3388 var = 0; /* don't use it for append */-
3389 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
3390 }
executed 1531 times by 1 test: end of block
Executed by:
  • Self test
1531
3391 else-
3392 newname = name_cell (var); /* no-op if not nameref */
executed 313 times by 1 test: newname = ((var)->name);
Executed by:
  • Self test
313
3393 -
3394 if (var && (readonly_p (var) || noassign_p (var)))
varDescription
TRUEevaluated 321 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1523 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000002)))Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 302 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 302 times by 1 test
Evaluated by:
  • Self test
0-1523
3395 {-
3396 if (readonly_p (var))
((((var)->attr... (0x0000002)))Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-19
3397 err_readonly (name);
executed 19 times by 1 test: err_readonly (name);
Executed by:
  • Self test
19
3398 free (name);-
3399 return (0);
executed 19 times by 1 test: return (0);
Executed by:
  • Self test
19
3400 }-
3401 temp = name + offset + 1;-
3402-
3403 value = expand_assignment_string_to_string (temp, 0);-
3404-
3405 if (var && (aflags & ASS_APPEND))
varDescription
TRUEevaluated 302 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1523 times by 1 test
Evaluated by:
  • Self test
(aflags & 0x0001)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 291 times by 1 test
Evaluated by:
  • Self test
11-1523
3406 {-
3407 if (value == 0)
value == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
3-8
3408 {-
3409 value = (char *)xmalloc (1); /* like do_assignment_internal */-
3410 value[0] = '\0';-
3411 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
3412 temp = make_variable_value (var, value, aflags);-
3413 FREE (value);
executed 11 times by 1 test: sh_xfree((value), "variables.c", 3413);
Executed by:
  • Self test
valueDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
3414 value = temp;-
3415 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
3416 }
executed 1825 times by 1 test: end of block
Executed by:
  • Self test
1825
3417-
3418 if (temporary_env == 0)
temporary_env == 0Description
TRUEevaluated 1753 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
72-1753
3419 temporary_env = hash_create (TEMPENV_HASH_BUCKETS);
executed 1753 times by 1 test: temporary_env = hash_create (4);
Executed by:
  • Self test
1753
3420-
3421 var = hash_lookup (newname, temporary_env);-
3422 if (var == 0)
var == 0Description
TRUEevaluated 1824 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-1824
3423 var = make_new_variable (newname, temporary_env);
executed 1824 times by 1 test: var = make_new_variable (newname, temporary_env);
Executed by:
  • Self test
1824
3424 else-
3425 FREE (value_cell (var));
executed 1 time by 1 test: sh_xfree((((var)->value)), "variables.c", 3425);
Executed by:
  • Self test
executed 1 time by 1 test: end of block
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
3426-
3427 if (value == 0)
value == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1809 times by 1 test
Evaluated by:
  • Self test
16-1809
3428 {-
3429 value = (char *)xmalloc (1); /* see above */-
3430 value[0] = '\0';-
3431 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
3432-
3433 var_setvalue (var, value);-
3434 var->attributes |= (att_exported|att_tempvar);-
3435 var->context = variable_context; /* XXX */-
3436-
3437 INVALIDATE_EXPORTSTR (var);
executed 1 time by 1 test: end of block
Executed by:
  • Self test
(var)->exportstrDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1824 times by 1 test
Evaluated by:
  • Self test
1-1824
3438 var->exportstr = mk_env_string (newname, value, 0);-
3439-
3440 array_needs_making = 1;-
3441-
3442 if (flags)
flagsDescription
TRUEevaluated 1787 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-1787
3443 stupidly_hack_special_variables (newname);
executed 1787 times by 1 test: stupidly_hack_special_variables (newname);
Executed by:
  • Self test
1787
3444-
3445 if (echo_command_at_execute)
echo_command_at_executeDescription
TRUEnever evaluated
FALSEevaluated 1825 times by 1 test
Evaluated by:
  • Self test
0-1825
3446 /* The Korn shell prints the `+ ' in front of assignment statements,-
3447 so we do too. */-
3448 xtrace_print_assignment (name, value, 0, 1);
never executed: xtrace_print_assignment (name, value, 0, 1);
0
3449-
3450 free (name);-
3451 return 1;
executed 1825 times by 1 test: return 1;
Executed by:
  • Self test
1825
3452}-
3453-
3454/* **************************************************************** */-
3455/* */-
3456/* Copying variables */-
3457/* */-
3458/* **************************************************************** */-
3459-
3460#ifdef INCLUDE_UNUSED-
3461/* Copy VAR to a new data structure and return that structure. */-
3462SHELL_VAR *-
3463copy_variable (var)-
3464 SHELL_VAR *var;-
3465{-
3466 SHELL_VAR *copy = (SHELL_VAR *)NULL;-
3467-
3468 if (var)-
3469 {-
3470 copy = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));-
3471-
3472 copy->attributes = var->attributes;-
3473 copy->name = savestring (var->name);-
3474-
3475 if (function_p (var))-
3476 var_setfunc (copy, copy_command (function_cell (var)));-
3477#if defined (ARRAY_VARS)-
3478 else if (array_p (var))-
3479 var_setarray (copy, array_copy (array_cell (var)));-
3480 else if (assoc_p (var))-
3481 var_setassoc (copy, assoc_copy (assoc_cell (var)));-
3482#endif-
3483 else if (nameref_cell (var)) /* XXX - nameref */-
3484 var_setref (copy, savestring (nameref_cell (var)));-
3485 else if (value_cell (var)) /* XXX - nameref */-
3486 var_setvalue (copy, savestring (value_cell (var)));-
3487 else-
3488 var_setvalue (copy, (char *)NULL);-
3489-
3490 copy->dynamic_value = var->dynamic_value;-
3491 copy->assign_func = var->assign_func;-
3492-
3493 copy->exportstr = COPY_EXPORTSTR (var);-
3494-
3495 copy->context = var->context;-
3496 }-
3497 return (copy);-
3498}-
3499#endif-
3500-
3501/* **************************************************************** */-
3502/* */-
3503/* Deleting and unsetting variables */-
3504/* */-
3505/* **************************************************************** */-
3506-
3507/* Dispose of the information attached to VAR. */-
3508static void-
3509dispose_variable_value (var)-
3510 SHELL_VAR *var;-
3511{-
3512 if (function_p (var))
((((var)->attr... (0x0000008)))Description
TRUEevaluated 4653 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10648 times by 1 test
Evaluated by:
  • Self test
4653-10648
3513 dispose_command (function_cell (var));
executed 4653 times by 1 test: dispose_command ((COMMAND *)((var)->value));
Executed by:
  • Self test
4653
3514#if defined (ARRAY_VARS)-
3515 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 458 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10190 times by 1 test
Evaluated by:
  • Self test
458-10190
3516 array_dispose (array_cell (var));
executed 458 times by 1 test: array_dispose ((ARRAY *)((var)->value));
Executed by:
  • Self test
458
3517 else if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10119 times by 1 test
Evaluated by:
  • Self test
71-10119
3518 assoc_dispose (assoc_cell (var));
executed 71 times by 1 test: assoc_dispose ((HASH_TABLE *)((var)->value));
Executed by:
  • Self test
71
3519#endif-
3520 else if (nameref_p (var))
((((var)->attr... (0x0000800)))Description
TRUEevaluated 189 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9930 times by 1 test
Evaluated by:
  • Self test
189-9930
3521 FREE (nameref_cell (var));
executed 113 times by 1 test: sh_xfree((((var)->value)), "variables.c", 3521);
Executed by:
  • Self test
executed 189 times by 1 test: end of block
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
76-189
3522 else-
3523 FREE (value_cell (var));
executed 9721 times by 1 test: sh_xfree((((var)->value)), "variables.c", 3523);
Executed by:
  • Self test
executed 9930 times by 1 test: end of block
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 9721 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
209-9930
3524}-
3525-
3526void-
3527dispose_variable (var)-
3528 SHELL_VAR *var;-
3529{-
3530 if (var == 0)
var == 0Description
TRUEnever evaluated
FALSEevaluated 15314 times by 1 test
Evaluated by:
  • Self test
0-15314
3531 return;
never executed: return;
0
3532-
3533 if (nofree_p (var) == 0)
((((var)->attr...020000))) == 0Description
TRUEevaluated 15284 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
30-15284
3534 dispose_variable_value (var);
executed 15284 times by 1 test: dispose_variable_value (var);
Executed by:
  • Self test
15284
3535-
3536 FREE_EXPORTSTR (var);
executed 2162 times by 1 test: sh_xfree(((var)->exportstr), "variables.c", 3536);
Executed by:
  • Self test
(var)->exportstrDescription
TRUEevaluated 2162 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13152 times by 1 test
Evaluated by:
  • Self test
2162-13152
3537-
3538 free (var->name);-
3539-
3540 if (exported_p (var))
((((var)->attr... (0x0000001)))Description
TRUEevaluated 2205 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13109 times by 1 test
Evaluated by:
  • Self test
2205-13109
3541 array_needs_making = 1;
executed 2205 times by 1 test: array_needs_making = 1;
Executed by:
  • Self test
2205
3542-
3543 free (var);-
3544}
executed 15314 times by 1 test: end of block
Executed by:
  • Self test
15314
3545-
3546/* Unset the shell variable referenced by NAME. Unsetting a nameref variable-
3547 unsets the variable it resolves to but leaves the nameref alone. */-
3548int-
3549unbind_variable (name)-
3550 const char *name;-
3551{-
3552 SHELL_VAR *v, *nv;-
3553 int r;-
3554-
3555 v = var_lookup (name, shell_variables);-
3556 nv = (v && nameref_p (v)) ? find_variable_nameref (v) : (SHELL_VAR *)NULL;
vDescription
TRUEevaluated 7118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12794 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7109 times by 1 test
Evaluated by:
  • Self test
9-12794
3557-
3558 r = nv ? makunbound (nv->name, shell_variables) : makunbound (name, shell_variables);
nvDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19909 times by 1 test
Evaluated by:
  • Self test
3-19909
3559 return r;
executed 19912 times by 1 test: return r;
Executed by:
  • Self test
19912
3560}-
3561-
3562/* Unbind NAME, where NAME is assumed to be a nameref variable */-
3563int-
3564unbind_nameref (name)-
3565 const char *name;-
3566{-
3567 SHELL_VAR *v;-
3568-
3569 v = var_lookup (name, shell_variables);-
3570 if (v && nameref_p (v))
vDescription
TRUEevaluated 138 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
29-138
3571 return makunbound (name, shell_variables);
executed 109 times by 1 test: return makunbound (name, shell_variables);
Executed by:
  • Self test
109
3572 return 0;
executed 71 times by 1 test: return 0;
Executed by:
  • Self test
71
3573}-
3574-
3575/* Unbind the first instance of NAME, whether it's a nameref or not */-
3576int-
3577unbind_variable_noref (name)-
3578 const char *name;-
3579{-
3580 SHELL_VAR *v;-
3581-
3582 v = var_lookup (name, shell_variables);-
3583 if (v)
vDescription
TRUEevaluated 143 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5570 times by 1 test
Evaluated by:
  • Self test
143-5570
3584 return makunbound (name, shell_variables);
executed 143 times by 1 test: return makunbound (name, shell_variables);
Executed by:
  • Self test
143
3585 return 0;
executed 5570 times by 1 test: return 0;
Executed by:
  • Self test
5570
3586}-
3587-
3588int-
3589check_unbind_variable (name)-
3590 const char *name;-
3591{-
3592 SHELL_VAR *v;-
3593-
3594 v = find_variable (name);-
3595 if (v && readonly_p (v))
vDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000002)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
6-15
3596 {-
3597 internal_error (_("%s: cannot unset: readonly %s"), name, "variable");-
3598 return -1;
executed 6 times by 1 test: return -1;
Executed by:
  • Self test
6
3599 }-
3600 return (unbind_variable (name));
executed 15 times by 1 test: return (unbind_variable (name));
Executed by:
  • Self test
15
3601}-
3602-
3603/* Unset the shell function named NAME. */-
3604int-
3605unbind_func (name)-
3606 const char *name;-
3607{-
3608 BUCKET_CONTENTS *elt;-
3609 SHELL_VAR *func;-
3610-
3611 elt = hash_remove (name, shell_functions, 0);-
3612-
3613 if (elt == 0)
elt == 0Description
TRUEevaluated 1734 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4649 times by 1 test
Evaluated by:
  • Self test
1734-4649
3614 return -1;
executed 1734 times by 1 test: return -1;
Executed by:
  • Self test
1734
3615-
3616#if defined (PROGRAMMABLE_COMPLETION)-
3617 set_itemlist_dirty (&it_functions);-
3618#endif-
3619-
3620 func = (SHELL_VAR *)elt->data;-
3621 if (func)
funcDescription
TRUEevaluated 4649 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4649
3622 {-
3623 if (exported_p (func))
((((func)->att... (0x0000001)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4648 times by 1 test
Evaluated by:
  • Self test
1-4648
3624 array_needs_making++;
executed 1 time by 1 test: array_needs_making++;
Executed by:
  • Self test
1
3625 dispose_variable (func);-
3626 }
executed 4649 times by 1 test: end of block
Executed by:
  • Self test
4649
3627-
3628 free (elt->key);-
3629 free (elt);-
3630-
3631 return 0;
executed 4649 times by 1 test: return 0;
Executed by:
  • Self test
4649
3632}-
3633-
3634#if defined (DEBUGGER)-
3635int-
3636unbind_function_def (name)-
3637 const char *name;-
3638{-
3639 BUCKET_CONTENTS *elt;-
3640 FUNCTION_DEF *funcdef;-
3641-
3642 elt = hash_remove (name, shell_function_defs, 0);-
3643-
3644 if (elt == 0)
elt == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3645 return -1;
never executed: return -1;
0
3646-
3647 funcdef = (FUNCTION_DEF *)elt->data;-
3648 if (funcdef)
funcdefDescription
TRUEnever evaluated
FALSEnever evaluated
0
3649 dispose_function_def (funcdef);
never executed: dispose_function_def (funcdef);
0
3650-
3651 free (elt->key);-
3652 free (elt);-
3653-
3654 return 0;
never executed: return 0;
0
3655}-
3656#endif /* DEBUGGER */-
3657-
3658int-
3659delete_var (name, vc)-
3660 const char *name;-
3661 VAR_CONTEXT *vc;-
3662{-
3663 BUCKET_CONTENTS *elt;-
3664 SHELL_VAR *old_var;-
3665 VAR_CONTEXT *v;-
3666-
3667 for (elt = (BUCKET_CONTENTS *)NULL, v = vc; v; v = v->down)
vDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
3668 if (elt = hash_remove (name, v->table, 0))
elt = hash_rem..., v->table, 0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
3669 break;
executed 8 times by 1 test: break;
Executed by:
  • Self test
8
3670-
3671 if (elt == 0)
elt == 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-8
3672 return (-1);
never executed: return (-1);
0
3673-
3674 old_var = (SHELL_VAR *)elt->data;-
3675 free (elt->key);-
3676 free (elt);-
3677-
3678 dispose_variable (old_var);-
3679 return (0);
executed 8 times by 1 test: return (0);
Executed by:
  • Self test
8
3680}-
3681-
3682/* Make the variable associated with NAME go away. HASH_LIST is the-
3683 hash table from which this variable should be deleted (either-
3684 shell_variables or shell_functions).-
3685 Returns non-zero if the variable couldn't be found. */-
3686int-
3687makunbound (name, vc)-
3688 const char *name;-
3689 VAR_CONTEXT *vc;-
3690{-
3691 BUCKET_CONTENTS *elt, *new_elt;-
3692 SHELL_VAR *old_var;-
3693 VAR_CONTEXT *v;-
3694 char *t;-
3695-
3696 for (elt = (BUCKET_CONTENTS *)NULL, v = vc; v; v = v->down)
vDescription
TRUEevaluated 25666 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12794 times by 1 test
Evaluated by:
  • Self test
12794-25666
3697 if (elt = hash_remove (name, v->table, 0))
elt = hash_rem..., v->table, 0)Description
TRUEevaluated 7370 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18296 times by 1 test
Evaluated by:
  • Self test
7370-18296
3698 break;
executed 7370 times by 1 test: break;
Executed by:
  • Self test
7370
3699-
3700 if (elt == 0)
elt == 0Description
TRUEevaluated 12794 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7370 times by 1 test
Evaluated by:
  • Self test
7370-12794
3701 return (-1);
executed 12794 times by 1 test: return (-1);
Executed by:
  • Self test
12794
3702-
3703 old_var = (SHELL_VAR *)elt->data;-
3704-
3705 if (old_var && exported_p (old_var))
old_varDescription
TRUEevaluated 7370 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((old_var)->... (0x0000001)))Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7323 times by 1 test
Evaluated by:
  • Self test
0-7370
3706 array_needs_making++;
executed 47 times by 1 test: array_needs_making++;
Executed by:
  • Self test
47
3707-
3708 /* If we're unsetting a local variable and we're still executing inside-
3709 the function, just mark the variable as invisible. The function-
3710 eventually called by pop_var_context() will clean it up later. This-
3711 must be done so that if the variable is subsequently assigned a new-
3712 value inside the function, the `local' attribute is still present.-
3713 We also need to add it back into the correct hash table. */-
3714 if (old_var && local_p (old_var) &&
old_varDescription
TRUEevaluated 7370 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((old_var)->... (0x0000020)))Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7359 times by 1 test
Evaluated by:
  • Self test
0-7370
3715 (old_var->context == variable_context || (localvar_unset && old_var->context < variable_context)))
old_var->conte...riable_contextDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
localvar_unsetDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
old_var->conte...riable_contextDescription
TRUEnever evaluated
FALSEnever evaluated
0-9
3716 {-
3717 if (nofree_p (old_var))
((((old_var)->... (0x0020000)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
3718 var_setvalue (old_var, (char *)NULL);
never executed: ((old_var)->value = ((char *) ((void *)0) ));
0
3719#if defined (ARRAY_VARS)-
3720 else if (array_p (old_var))
((((old_var)->... (0x0000004)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
3721 array_dispose (array_cell (old_var));
never executed: array_dispose ((ARRAY *)((old_var)->value));
0
3722 else if (assoc_p (old_var))
((((old_var)->... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
3723 assoc_dispose (assoc_cell (old_var));
never executed: assoc_dispose ((HASH_TABLE *)((old_var)->value));
0
3724#endif-
3725 else if (nameref_p (old_var))
((((old_var)->... (0x0000800)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
3726 FREE (nameref_cell (old_var));
never executed: sh_xfree((((old_var)->value)), "variables.c", 3726);
never executed: end of block
((old_var)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
3727 else-
3728 FREE (value_cell (old_var));
executed 9 times by 1 test: sh_xfree((((old_var)->value)), "variables.c", 3728);
Executed by:
  • Self test
executed 9 times by 1 test: end of block
Executed by:
  • Self test
((old_var)->value)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9
3729 /* Reset the attributes. Preserve the export attribute if the variable-
3730 came from a temporary environment. Make sure it stays local, and-
3731 make it invisible. */ -
3732 old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
((((old_var)->... (0x0000001)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
((((old_var)->... (0x0100000)))Description
TRUEnever evaluated
FALSEnever evaluated
0-9
3733 VSETATTR (old_var, att_local);-
3734 VSETATTR (old_var, att_invisible);-
3735 var_setvalue (old_var, (char *)NULL);-
3736 INVALIDATE_EXPORTSTR (old_var);
never executed: end of block
(old_var)->exportstrDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
3737-
3738 new_elt = hash_insert (savestring (old_var->name), v->table, 0);-
3739 new_elt->data = (PTR_T)old_var;-
3740 stupidly_hack_special_variables (old_var->name);-
3741-
3742 free (elt->key);-
3743 free (elt);-
3744 return (0);
executed 9 times by 1 test: return (0);
Executed by:
  • Self test
9
3745 }-
3746-
3747 /* Have to save a copy of name here, because it might refer to-
3748 old_var->name. If so, stupidly_hack_special_variables will-
3749 reference freed memory. */-
3750 t = savestring (name);-
3751-
3752 free (elt->key);-
3753 free (elt);-
3754-
3755 dispose_variable (old_var);-
3756 stupidly_hack_special_variables (t);-
3757 free (t);-
3758-
3759 return (0);
executed 7361 times by 1 test: return (0);
Executed by:
  • Self test
7361
3760}-
3761-
3762/* Get rid of all of the variables in the current context. */-
3763void-
3764kill_all_local_variables ()-
3765{-
3766 VAR_CONTEXT *vc;-
3767-
3768 for (vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEnever evaluated
FALSEnever evaluated
0
3769 if (vc_isfuncenv (vc) && vc->scope == variable_context)
(((vc)->flags & 0x04) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
vc->scope == variable_contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
3770 break;
never executed: break;
0
3771 if (vc == 0)
vc == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3772 return; /* XXX */
never executed: return;
0
3773-
3774 if (vc->table && vc_haslocals (vc))
vc->tableDescription
TRUEnever evaluated
FALSEnever evaluated
(((vc)->flags & 0x01) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
3775 {-
3776 delete_all_variables (vc->table);-
3777 hash_dispose (vc->table);-
3778 }
never executed: end of block
0
3779 vc->table = (HASH_TABLE *)NULL;-
3780}
never executed: end of block
0
3781-
3782static void-
3783free_variable_hash_data (data)-
3784 PTR_T data;-
3785{-
3786 SHELL_VAR *var;-
3787-
3788 var = (SHELL_VAR *)data;-
3789 dispose_variable (var);-
3790}
executed 950 times by 1 test: end of block
Executed by:
  • Self test
950
3791-
3792/* Delete the entire contents of the hash table. */-
3793void-
3794delete_all_variables (hashed_vars)-
3795 HASH_TABLE *hashed_vars;-
3796{-
3797 hash_flush (hashed_vars, free_variable_hash_data);-
3798}
executed 353 times by 1 test: end of block
Executed by:
  • Self test
353
3799-
3800/* **************************************************************** */-
3801/* */-
3802/* Setting variable attributes */-
3803/* */-
3804/* **************************************************************** */-
3805-
3806#define FIND_OR_MAKE_VARIABLE(name, entry) \-
3807 do \-
3808 { \-
3809 entry = find_variable (name); \-
3810 if (!entry) \-
3811 { \-
3812 entry = bind_variable (name, "", 0); \-
3813 if (!no_invisible_vars && entry) entry->attributes |= att_invisible; \-
3814 } \-
3815 } \-
3816 while (0)-
3817-
3818/* Make the variable associated with NAME be readonly.-
3819 If NAME does not exist yet, create it. */-
3820void-
3821set_var_read_only (name)-
3822 char *name;-
3823{-
3824 SHELL_VAR *entry;-
3825-
3826 FIND_OR_MAKE_VARIABLE (name, entry);
executed 2 times by 1 test: entry->attributes |= 0x0001000;
Executed by:
  • Self test
executed 2 times by 1 test: end of block
Executed by:
  • Self test
!entryDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
!no_invisible_varsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
entryDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
3827 VSETATTR (entry, att_readonly);-
3828}
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
3829-
3830#ifdef INCLUDE_UNUSED-
3831/* Make the function associated with NAME be readonly.-
3832 If NAME does not exist, we just punt, like auto_export code below. */-
3833void-
3834set_func_read_only (name)-
3835 const char *name;-
3836{-
3837 SHELL_VAR *entry;-
3838-
3839 entry = find_function (name);-
3840 if (entry)-
3841 VSETATTR (entry, att_readonly);-
3842}-
3843-
3844/* Make the variable associated with NAME be auto-exported.-
3845 If NAME does not exist yet, create it. */-
3846void-
3847set_var_auto_export (name)-
3848 char *name;-
3849{-
3850 SHELL_VAR *entry;-
3851-
3852 FIND_OR_MAKE_VARIABLE (name, entry);-
3853 set_auto_export (entry);-
3854}-
3855-
3856/* Make the function associated with NAME be auto-exported. */-
3857void-
3858set_func_auto_export (name)-
3859 const char *name;-
3860{-
3861 SHELL_VAR *entry;-
3862-
3863 entry = find_function (name);-
3864 if (entry)-
3865 set_auto_export (entry);-
3866}-
3867#endif-
3868-
3869/* **************************************************************** */-
3870/* */-
3871/* Creating lists of variables */-
3872/* */-
3873/* **************************************************************** */-
3874-
3875static VARLIST *-
3876vlist_alloc (nentries)-
3877 int nentries;-
3878{-
3879 VARLIST *vlist;-
3880-
3881 vlist = (VARLIST *)xmalloc (sizeof (VARLIST));-
3882 vlist->list = (SHELL_VAR **)xmalloc ((nentries + 1) * sizeof (SHELL_VAR *));-
3883 vlist->list_size = nentries;-
3884 vlist->list_len = 0;-
3885 vlist->list[0] = (SHELL_VAR *)NULL;-
3886-
3887 return vlist;
executed 18792 times by 1 test: return vlist;
Executed by:
  • Self test
18792
3888}-
3889-
3890static VARLIST *-
3891vlist_realloc (vlist, n)-
3892 VARLIST *vlist;-
3893 int n;-
3894{-
3895 if (vlist == 0)
vlist == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3896 return (vlist = vlist_alloc (n));
never executed: return (vlist = vlist_alloc (n));
0
3897 if (n > vlist->list_size)
n > vlist->list_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3898 {-
3899 vlist->list_size = n;-
3900 vlist->list = (SHELL_VAR **)xrealloc (vlist->list, (vlist->list_size + 1) * sizeof (SHELL_VAR *));-
3901 }
never executed: end of block
0
3902 return vlist;
never executed: return vlist;
0
3903}-
3904-
3905static void-
3906vlist_add (vlist, var, flags)-
3907 VARLIST *vlist;-
3908 SHELL_VAR *var;-
3909 int flags;-
3910{-
3911 register int i;-
3912-
3913 for (i = 0; i < vlist->list_len; i++)
i < vlist->list_lenDescription
TRUEevaluated 3523014 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 322045 times by 1 test
Evaluated by:
  • Self test
322045-3523014
3914 if (STREQ (var->name, vlist->list[i]->name))
never executed: __result = (((const unsigned char *) (const char *) ( var->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( vlist->list[i]->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(var->name)[0]...t[i]->name)[0]Description
TRUEevaluated 318842 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3204172 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 318815 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-3204172
3915 break;
executed 27 times by 1 test: break;
Executed by:
  • Self test
27
3916 if (i < vlist->list_len)
i < vlist->list_lenDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 322045 times by 1 test
Evaluated by:
  • Self test
27-322045
3917 return;
executed 27 times by 1 test: return;
Executed by:
  • Self test
27
3918-
3919 if (i >= vlist->list_size)
i >= vlist->list_sizeDescription
TRUEnever evaluated
FALSEevaluated 322045 times by 1 test
Evaluated by:
  • Self test
0-322045
3920 vlist = vlist_realloc (vlist, vlist->list_size + 16);
never executed: vlist = vlist_realloc (vlist, vlist->list_size + 16);
0
3921-
3922 vlist->list[vlist->list_len++] = var;-
3923 vlist->list[vlist->list_len] = (SHELL_VAR *)NULL;-
3924}
executed 322045 times by 1 test: end of block
Executed by:
  • Self test
322045
3925-
3926/* Map FUNCTION over the variables in VAR_HASH_TABLE. Return an array of the-
3927 variables for which FUNCTION returns a non-zero value. A NULL value-
3928 for FUNCTION means to use all variables. */-
3929SHELL_VAR **-
3930map_over (function, vc)-
3931 sh_var_map_func_t *function;-
3932 VAR_CONTEXT *vc;-
3933{-
3934 VAR_CONTEXT *v;-
3935 VARLIST *vlist;-
3936 SHELL_VAR **ret;-
3937 int nentries;-
3938-
3939 for (nentries = 0, v = vc; v; v = v->down)
vDescription
TRUEevaluated 18240 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14189 times by 1 test
Evaluated by:
  • Self test
14189-18240
3940 nentries += HASH_ENTRIES (v->table);
executed 18240 times by 1 test: nentries += ((v->table) ? (v->table)->nentries : 0);
Executed by:
  • Self test
(v->table)Description
TRUEevaluated 15689 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2551 times by 1 test
Evaluated by:
  • Self test
2551-18240
3941-
3942 if (nentries == 0)
nentries == 0Description
TRUEnever evaluated
FALSEevaluated 14189 times by 1 test
Evaluated by:
  • Self test
0-14189
3943 return (SHELL_VAR **)NULL;
never executed: return (SHELL_VAR **) ((void *)0) ;
0
3944-
3945 vlist = vlist_alloc (nentries);-
3946-
3947 for (v = vc; v; v = v->down)
vDescription
TRUEevaluated 18240 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14189 times by 1 test
Evaluated by:
  • Self test
14189-18240
3948 flatten (v->table, function, vlist, 0);
executed 18240 times by 1 test: flatten (v->table, function, vlist, 0);
Executed by:
  • Self test
18240
3949-
3950 ret = vlist->list;-
3951 free (vlist);-
3952 return ret;
executed 14189 times by 1 test: return ret;
Executed by:
  • Self test
14189
3953}-
3954-
3955SHELL_VAR **-
3956map_over_funcs (function)-
3957 sh_var_map_func_t *function;-
3958{-
3959 VARLIST *vlist;-
3960 SHELL_VAR **ret;-
3961-
3962 if (shell_functions == 0 || HASH_ENTRIES (shell_functions) == 0)
(shell_functions)Description
TRUEevaluated 14180 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
shell_functions == 0Description
TRUEnever evaluated
FALSEevaluated 14180 times by 1 test
Evaluated by:
  • Self test
((shell_functi...ries : 0) == 0Description
TRUEevaluated 9580 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4600 times by 1 test
Evaluated by:
  • Self test
0-14180
3963 return ((SHELL_VAR **)NULL);
executed 9580 times by 1 test: return ((SHELL_VAR **) ((void *)0) );
Executed by:
  • Self test
9580
3964-
3965 vlist = vlist_alloc (HASH_ENTRIES (shell_functions));-
3966-
3967 flatten (shell_functions, function, vlist, 0);-
3968-
3969 ret = vlist->list;-
3970 free (vlist);-
3971 return ret;
executed 4600 times by 1 test: return ret;
Executed by:
  • Self test
4600
3972}-
3973-
3974/* Flatten VAR_HASH_TABLE, applying FUNC to each member and adding those-
3975 elements for which FUNC succeeds to VLIST->list. FLAGS is reserved-
3976 for future use. Only unique names are added to VLIST. If FUNC is-
3977 NULL, each variable in VAR_HASH_TABLE is added to VLIST. If VLIST is-
3978 NULL, FUNC is applied to each SHELL_VAR in VAR_HASH_TABLE. If VLIST-
3979 and FUNC are both NULL, nothing happens. */-
3980static void-
3981flatten (var_hash_table, func, vlist, flags)-
3982 HASH_TABLE *var_hash_table;-
3983 sh_var_map_func_t *func;-
3984 VARLIST *vlist;-
3985 int flags;-
3986{-
3987 register int i;-
3988 register BUCKET_CONTENTS *tlist;-
3989 int r;-
3990 SHELL_VAR *var;-
3991-
3992 if (var_hash_table == 0 || (HASH_ENTRIES (var_hash_table) == 0) || (vlist == 0 && func == 0))
(var_hash_table)Description
TRUEevaluated 20448 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
var_hash_table == 0Description
TRUEevaluated 2551 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20448 times by 1 test
Evaluated by:
  • Self test
(((var_hash_ta...ies : 0) == 0)Description
TRUEnever evaluated
FALSEevaluated 20448 times by 1 test
Evaluated by:
  • Self test
vlist == 0Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20292 times by 1 test
Evaluated by:
  • Self test
func == 0Description
TRUEnever evaluated
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
0-20448
3993 return;
executed 2551 times by 1 test: return;
Executed by:
  • Self test
2551
3994-
3995 for (i = 0; i < var_hash_table->nbuckets; i++)
i < var_hash_table->nbucketsDescription
TRUEevaluated 16891372 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20448 times by 1 test
Evaluated by:
  • Self test
20448-16891372
3996 {-
3997 for (tlist = hash_items (i, var_hash_table); tlist; tlist = tlist->next)
tlistDescription
TRUEevaluated 941646 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16891372 times by 1 test
Evaluated by:
  • Self test
941646-16891372
3998 {-
3999 var = (SHELL_VAR *)tlist->data;-
4000-
4001 r = func ? (*func) (var) : 1;
funcDescription
TRUEevaluated 940026 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1620 times by 1 test
Evaluated by:
  • Self test
1620-940026
4002 if (r && vlist)
rDescription
TRUEevaluated 322164 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 619482 times by 1 test
Evaluated by:
  • Self test
vlistDescription
TRUEevaluated 322072 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 92 times by 1 test
Evaluated by:
  • Self test
92-619482
4003 vlist_add (vlist, var, flags);
executed 322072 times by 1 test: vlist_add (vlist, var, flags);
Executed by:
  • Self test
322072
4004 }
executed 941646 times by 1 test: end of block
Executed by:
  • Self test
941646
4005 }
executed 16891372 times by 1 test: end of block
Executed by:
  • Self test
16891372
4006}
executed 20448 times by 1 test: end of block
Executed by:
  • Self test
20448
4007-
4008void-
4009sort_variables (array)-
4010 SHELL_VAR **array;-
4011{-
4012 qsort (array, strvec_len ((char **)array), sizeof (SHELL_VAR *), (QSFUNC *)qsort_var_comp);-
4013}
executed 52 times by 1 test: end of block
Executed by:
  • Self test
52
4014-
4015static int-
4016qsort_var_comp (var1, var2)-
4017 SHELL_VAR **var1, **var2;-
4018{-
4019 int result;-
4020-
4021 if ((result = (*var1)->name[0] - (*var2)->name[0]) == 0)
(result = (*va...>name[0]) == 0Description
TRUEevaluated 2788 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6949 times by 1 test
Evaluated by:
  • Self test
2788-6949
4022 result = strcmp ((*var1)->name, (*var2)->name);
executed 2788 times by 1 test: result = __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( (*var1)->name ) && __builtin_constant_p ( (*var2)->name ) && (__s1_len = __builtin_strlen ( (*var1)->name ), __s2_len = __builtin_strlen ( (*var2)->name ), (!((size_t)(const void...r *) (const char *) ( (*var2)->name ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( (*var2)->name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( (*var1)->name , (*var2)->name )))); }) ;
Executed by:
  • Self test
never executed: __result = (((const unsigned char *) (const char *) ( (*var1)->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( (*var2)->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2788
4023-
4024 return (result);
executed 9737 times by 1 test: return (result);
Executed by:
  • Self test
9737
4025}-
4026-
4027/* Apply FUNC to each variable in SHELL_VARIABLES, adding each one for-
4028 which FUNC succeeds to an array of SHELL_VAR *s. Returns the array. */-
4029static SHELL_VAR **-
4030vapply (func)-
4031 sh_var_map_func_t *func;-
4032{-
4033 SHELL_VAR **list;-
4034-
4035 list = map_over (func, shell_variables);-
4036 if (list /* && posixly_correct */)
listDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-30
4037 sort_variables (list);
executed 30 times by 1 test: sort_variables (list);
Executed by:
  • Self test
30
4038 return (list);
executed 30 times by 1 test: return (list);
Executed by:
  • Self test
30
4039}-
4040-
4041/* Apply FUNC to each variable in SHELL_FUNCTIONS, adding each one for-
4042 which FUNC succeeds to an array of SHELL_VAR *s. Returns the array. */-
4043static SHELL_VAR **-
4044fapply (func)-
4045 sh_var_map_func_t *func;-
4046{-
4047 SHELL_VAR **list;-
4048-
4049 list = map_over_funcs (func);-
4050 if (list /* && posixly_correct */)
listDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-19
4051 sort_variables (list);
executed 19 times by 1 test: sort_variables (list);
Executed by:
  • Self test
19
4052 return (list);
executed 21 times by 1 test: return (list);
Executed by:
  • Self test
21
4053}-
4054-
4055/* Create a NULL terminated array of all the shell variables. */-
4056SHELL_VAR **-
4057all_shell_variables ()-
4058{-
4059 return (vapply ((sh_var_map_func_t *)NULL));
executed 23 times by 1 test: return (vapply ((sh_var_map_func_t *) ((void *)0) ));
Executed by:
  • Self test
23
4060}-
4061-
4062/* Create a NULL terminated array of all the shell functions. */-
4063SHELL_VAR **-
4064all_shell_functions ()-
4065{-
4066 return (fapply ((sh_var_map_func_t *)NULL));
executed 21 times by 1 test: return (fapply ((sh_var_map_func_t *) ((void *)0) ));
Executed by:
  • Self test
21
4067}-
4068-
4069static int-
4070visible_var (var)-
4071 SHELL_VAR *var;-
4072{-
4073 return (invisible_p (var) == 0);
executed 469 times by 1 test: return (((((var)->attributes) & (0x0001000))) == 0);
Executed by:
  • Self test
469
4074}-
4075-
4076SHELL_VAR **-
4077all_visible_functions ()-
4078{-
4079 return (fapply (visible_var));
never executed: return (fapply (visible_var));
0
4080}-
4081-
4082SHELL_VAR **-
4083all_visible_variables ()-
4084{-
4085 return (vapply (visible_var));
executed 7 times by 1 test: return (vapply (visible_var));
Executed by:
  • Self test
7
4086}-
4087-
4088/* Return non-zero if the variable VAR is visible and exported. Array-
4089 variables cannot be exported. */-
4090static int-
4091visible_and_exported (var)-
4092 SHELL_VAR *var;-
4093{-
4094 return (invisible_p (var) == 0 && exported_p (var));
executed 10560 times by 1 test: return (((((var)->attributes) & (0x0001000))) == 0 && ((((var)->attributes) & (0x0000001))));
Executed by:
  • Self test
10560
4095}-
4096-
4097/* Candidate variables for the export environment are either valid variables-
4098 with the export attribute or invalid variables inherited from the initial-
4099 environment and simply passed through. */-
4100static int-
4101export_environment_candidate (var)-
4102 SHELL_VAR *var;-
4103{-
4104 return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var)));
executed 928814 times by 1 test: return (((((var)->attributes) & (0x0000001))) && (((((var)->attributes) & (0x0001000))) == 0 || ((((var)->attributes) & (0x0008000)))));
Executed by:
  • Self test
928814
4105}-
4106-
4107/* Return non-zero if VAR is a local variable in the current context and-
4108 is exported. */-
4109static int-
4110local_and_exported (var)-
4111 SHELL_VAR *var;-
4112{-
4113 return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context && exported_p (var));
never executed: return (((((var)->attributes) & (0x0001000))) == 0 && ((((var)->attributes) & (0x0000020))) && var->context == variable_context && ((((var)->attributes) & (0x0000001))));
0
4114}-
4115-
4116SHELL_VAR **-
4117all_exported_variables ()-
4118{-
4119 return (vapply (visible_and_exported));
never executed: return (vapply (visible_and_exported));
0
4120}-
4121-
4122SHELL_VAR **-
4123local_exported_variables ()-
4124{-
4125 return (vapply (local_and_exported));
never executed: return (vapply (local_and_exported));
0
4126}-
4127-
4128static int-
4129variable_in_context (var)-
4130 SHELL_VAR *var;-
4131{-
4132 return (invisible_p (var) == 0 && local_p (var) && var->context == variable_context);
executed 6 times by 1 test: return (((((var)->attributes) & (0x0001000))) == 0 && ((((var)->attributes) & (0x0000020))) && var->context == variable_context);
Executed by:
  • Self test
6
4133}-
4134-
4135SHELL_VAR **-
4136all_local_variables ()-
4137{-
4138 VARLIST *vlist;-
4139 SHELL_VAR **ret;-
4140 VAR_CONTEXT *vc;-
4141-
4142 vc = shell_variables;-
4143 for (vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4144 if (vc_isfuncenv (vc) && vc->scope == variable_context)
(((vc)->flags & 0x04) != 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
vc->scope == variable_contextDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4145 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
4146-
4147 if (vc == 0)
vc == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
4148 {-
4149 internal_error (_("all_local_variables: no function context at current scope"));-
4150 return (SHELL_VAR **)NULL;
never executed: return (SHELL_VAR **) ((void *)0) ;
0
4151 }-
4152 if (vc->table == 0 || HASH_ENTRIES (vc->table) == 0 || vc_haslocals (vc) == 0)
(vc->table)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
vc->table == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
((vc->table) ?...ries : 0) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(((vc)->flags ...01) != 0) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
4153 return (SHELL_VAR **)NULL;
never executed: return (SHELL_VAR **) ((void *)0) ;
0
4154 -
4155 vlist = vlist_alloc (HASH_ENTRIES (vc->table));-
4156-
4157 flatten (vc->table, variable_in_context, vlist, 0);-
4158-
4159 ret = vlist->list;-
4160 free (vlist);-
4161 if (ret)
retDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4162 sort_variables (ret);
executed 3 times by 1 test: sort_variables (ret);
Executed by:
  • Self test
3
4163 return ret;
executed 3 times by 1 test: return ret;
Executed by:
  • Self test
3
4164}-
4165-
4166#if defined (ARRAY_VARS)-
4167/* Return non-zero if the variable VAR is visible and an array. */-
4168static int-
4169visible_array_vars (var)-
4170 SHELL_VAR *var;-
4171{-
4172 return (invisible_p (var) == 0 && (array_p (var) || assoc_p (var)));
never executed: return (((((var)->attributes) & (0x0001000))) == 0 && (((((var)->attributes) & (0x0000004))) || ((((var)->attributes) & (0x0000040)))));
0
4173}-
4174-
4175SHELL_VAR **-
4176all_array_variables ()-
4177{-
4178 return (vapply (visible_array_vars));
never executed: return (vapply (visible_array_vars));
0
4179}-
4180#endif /* ARRAY_VARS */-
4181-
4182char **-
4183all_variables_matching_prefix (prefix)-
4184 const char *prefix;-
4185{-
4186 SHELL_VAR **varlist;-
4187 char **rlist;-
4188 int vind, rind, plen;-
4189-
4190 plen = STRLEN (prefix);
(prefix)[1]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(prefix)[2]Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(prefix)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(prefix)[0]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
4191 varlist = all_visible_variables ();-
4192 for (vind = 0; varlist && varlist[vind]; vind++)
varlistDescription
TRUEevaluated 469 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
varlist[vind]Description
TRUEevaluated 462 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-469
4193 ;
executed 462 times by 1 test: ;
Executed by:
  • Self test
462
4194 if (varlist == 0 || vind == 0)
varlist == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
vind == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-7
4195 return ((char **)NULL);
never executed: return ((char **) ((void *)0) );
0
4196 rlist = strvec_create (vind + 1);-
4197 for (vind = rind = 0; varlist[vind]; vind++)
varlist[vind]Description
TRUEevaluated 462 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7-462
4198 {-
4199 if (plen == 0 || STREQN (prefix, varlist[vind]->name, plen))
never executed: __result = (((const unsigned char *) (const char *) ( prefix ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( varlist[vind]->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(plen == 0)Description
TRUEnever evaluated
FALSEevaluated 462 times by 1 test
Evaluated by:
  • Self test
plen == 0Description
TRUEnever evaluated
FALSEevaluated 462 times by 1 test
Evaluated by:
  • Self test
((plen == 0) ?...len ))) == 0))Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 426 times by 1 test
Evaluated by:
  • Self test
(prefix)[0] ==...ind]->name)[0]Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 413 times by 1 test
Evaluated by:
  • Self test
(__extension__... plen ))) == 0Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( plen )Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( prefix )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( prefi...e_t) ( plen ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...[vind]->name )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( varli...e_t) ( plen ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-462
4200 rlist[rind++] = savestring (varlist[vind]->name);
executed 36 times by 1 test: rlist[rind++] = (char *)strcpy (sh_xmalloc((1 + strlen (varlist[vind]->name)), "variables.c", 4200), (varlist[vind]->name));
Executed by:
  • Self test
36
4201 }
executed 462 times by 1 test: end of block
Executed by:
  • Self test
462
4202 rlist[rind] = (char *)0;-
4203 free (varlist);-
4204-
4205 return rlist;
executed 7 times by 1 test: return rlist;
Executed by:
  • Self test
7
4206}-
4207-
4208/* **************************************************************** */-
4209/* */-
4210/* Managing temporary variable scopes */-
4211/* */-
4212/* **************************************************************** */-
4213-
4214/* Make variable NAME have VALUE in the temporary environment. */-
4215static SHELL_VAR *-
4216bind_tempenv_variable (name, value)-
4217 const char *name;-
4218 char *value;-
4219{-
4220 SHELL_VAR *var;-
4221-
4222 var = temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *)NULL;
temporary_envDescription
TRUEevaluated 2972 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2972
4223-
4224 if (var)
varDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2955 times by 1 test
Evaluated by:
  • Self test
17-2955
4225 {-
4226 FREE (value_cell (var));
executed 17 times by 1 test: sh_xfree((((var)->value)), "variables.c", 4226);
Executed by:
  • Self test
((var)->value)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
4227 var_setvalue (var, savestring (value));-
4228 INVALIDATE_EXPORTSTR (var);
executed 16 times by 1 test: end of block
Executed by:
  • Self test
(var)->exportstrDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-16
4229 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
4230-
4231 return (var);
executed 2972 times by 1 test: return (var);
Executed by:
  • Self test
2972
4232}-
4233-
4234/* Find a variable in the temporary environment that is named NAME.-
4235 Return the SHELL_VAR *, or NULL if not found. */-
4236SHELL_VAR *-
4237find_tempenv_variable (name)-
4238 const char *name;-
4239{-
4240 return (temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *)NULL);
executed 13467 times by 1 test: return (temporary_env ? hash_lookup (name, temporary_env) : (SHELL_VAR *) ((void *)0) );
Executed by:
  • Self test
13467
4241}-
4242-
4243char **tempvar_list;-
4244int tvlist_ind;-
4245-
4246/* Push the variable described by (SHELL_VAR *)DATA down to the next-
4247 variable context from the temporary environment. */-
4248static void-
4249push_temp_var (data)-
4250 PTR_T data;-
4251{-
4252 SHELL_VAR *var, *v;-
4253 HASH_TABLE *binding_table;-
4254-
4255 var = (SHELL_VAR *)data;-
4256-
4257 binding_table = shell_variables->table;-
4258 if (binding_table == 0)
binding_table == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
1-27
4259 {-
4260 if (shell_variables == global_variables)
shell_variable...obal_variablesDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
4261 /* shouldn't happen */-
4262 binding_table = shell_variables->table = global_variables->table = hash_create (VARIABLES_HASH_BUCKETS);
never executed: binding_table = shell_variables->table = global_variables->table = hash_create (1024);
0
4263 else-
4264 binding_table = shell_variables->table = hash_create (TEMPENV_HASH_BUCKETS);
executed 1 time by 1 test: binding_table = shell_variables->table = hash_create (4);
Executed by:
  • Self test
1
4265 }-
4266-
4267 v = bind_variable_internal (var->name, value_cell (var), binding_table, 0, ASS_FORCE|ASS_NOLONGJMP);-
4268-
4269 /* XXX - should we set the context here? It shouldn't matter because of how-
4270 assign_in_env works, but might want to check. */-
4271 if (binding_table == global_variables->table) /* XXX */
binding_table ...riables->tableDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-26
4272 var->attributes &= ~(att_tempvar|att_propagate);
executed 26 times by 1 test: var->attributes &= ~(0x0100000|0x0200000);
Executed by:
  • Self test
26
4273 else-
4274 {-
4275 var->attributes |= att_propagate;-
4276 if (binding_table == shell_variables->table)
binding_table ...riables->tableDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
4277 shell_variables->flags |= VC_HASTMPVAR;
executed 2 times by 1 test: shell_variables->flags |= 0x02;
Executed by:
  • Self test
2
4278 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
4279 if (v)
vDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28
4280 v->attributes |= var->attributes;
executed 28 times by 1 test: v->attributes |= var->attributes;
Executed by:
  • Self test
28
4281-
4282 if (find_special_var (var->name) >= 0)
find_special_v...ar->name) >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
1-27
4283 tempvar_list[tvlist_ind++] = savestring (var->name);
executed 1 time by 1 test: tempvar_list[tvlist_ind++] = (char *)strcpy (sh_xmalloc((1 + strlen (var->name)), "variables.c", 4283), (var->name));
Executed by:
  • Self test
1
4284-
4285 dispose_variable (var);-
4286}
executed 28 times by 1 test: end of block
Executed by:
  • Self test
28
4287-
4288static void-
4289propagate_temp_var (data)-
4290 PTR_T data;-
4291{-
4292 SHELL_VAR *var;-
4293-
4294 var = (SHELL_VAR *)data;-
4295 if (tempvar_p (var) && (var->attributes & att_propagate))
((((var)->attr... (0x0100000)))Description
TRUEevaluated 1620 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(var->attributes & 0x0200000)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1603 times by 1 test
Evaluated by:
  • Self test
0-1620
4296 push_temp_var (data);
executed 17 times by 1 test: push_temp_var (data);
Executed by:
  • Self test
17
4297 else-
4298 {-
4299 if (find_special_var (var->name) >= 0)
find_special_v...ar->name) >= 0Description
TRUEevaluated 1407 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196 times by 1 test
Evaluated by:
  • Self test
196-1407
4300 tempvar_list[tvlist_ind++] = savestring (var->name);
executed 1407 times by 1 test: tempvar_list[tvlist_ind++] = (char *)strcpy (sh_xmalloc((1 + strlen (var->name)), "variables.c", 4300), (var->name));
Executed by:
  • Self test
1407
4301 dispose_variable (var);-
4302 }
executed 1603 times by 1 test: end of block
Executed by:
  • Self test
1603
4303}-
4304-
4305/* Free the storage used in the hash table for temporary-
4306 environment variables. PUSHF is a function to be called-
4307 to free each hash table entry. It takes care of pushing variables-
4308 to previous scopes if appropriate. PUSHF stores names of variables-
4309 that require special handling (e.g., IFS) on tempvar_list, so this-
4310 function can call stupidly_hack_special_variables on all the-
4311 variables in the list when the temporary hash table is destroyed. */-
4312static void-
4313dispose_temporary_env (pushf)-
4314 sh_free_func_t *pushf;-
4315{-
4316 int i;-
4317-
4318 tempvar_list = strvec_create (HASH_ENTRIES (temporary_env) + 1);-
4319 tempvar_list[tvlist_ind = 0] = 0;-
4320 -
4321 hash_flush (temporary_env, pushf);-
4322 hash_dispose (temporary_env);-
4323 temporary_env = (HASH_TABLE *)NULL;-
4324-
4325 tempvar_list[tvlist_ind] = 0;-
4326-
4327 array_needs_making = 1;-
4328-
4329#if 0-
4330 sv_ifs ("IFS"); /* XXX here for now -- check setifs in assign_in_env */ -
4331#endif-
4332 for (i = 0; i < tvlist_ind; i++)
i < tvlist_indDescription
TRUEevaluated 1408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1581 times by 1 test
Evaluated by:
  • Self test
1408-1581
4333 stupidly_hack_special_variables (tempvar_list[i]);
executed 1408 times by 1 test: stupidly_hack_special_variables (tempvar_list[i]);
Executed by:
  • Self test
1408
4334-
4335 strvec_dispose (tempvar_list);-
4336 tempvar_list = 0;-
4337 tvlist_ind = 0;-
4338}
executed 1581 times by 1 test: end of block
Executed by:
  • Self test
1581
4339-
4340void-
4341dispose_used_env_vars ()-
4342{-
4343 if (temporary_env)
temporary_envDescription
TRUEevaluated 1570 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64697866 times by 1 test
Evaluated by:
  • Self test
1570-64697866
4344 {-
4345 dispose_temporary_env (propagate_temp_var);-
4346 maybe_make_export_env ();-
4347 }
executed 1570 times by 1 test: end of block
Executed by:
  • Self test
1570
4348}
executed 64699436 times by 1 test: end of block
Executed by:
  • Self test
64699436
4349-
4350/* Take all of the shell variables in the temporary environment HASH_TABLE-
4351 and make shell variables from them at the current variable context. */-
4352void-
4353merge_temporary_env ()-
4354{-
4355 if (temporary_env)
temporary_envDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
4356 dispose_temporary_env (push_temp_var);
executed 11 times by 1 test: dispose_temporary_env (push_temp_var);
Executed by:
  • Self test
11
4357}
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
4358-
4359void-
4360flush_temporary_env ()-
4361{-
4362 if (temporary_env)
temporary_envDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1360 times by 1 test
Evaluated by:
  • Self test
13-1360
4363 {-
4364 hash_flush (temporary_env, free_variable_hash_data);-
4365 hash_dispose (temporary_env);-
4366 temporary_env = (HASH_TABLE *)NULL;-
4367 }
executed 13 times by 1 test: end of block
Executed by:
  • Self test
13
4368}
executed 1373 times by 1 test: end of block
Executed by:
  • Self test
1373
4369-
4370/* **************************************************************** */-
4371/* */-
4372/* Creating and manipulating the environment */-
4373/* */-
4374/* **************************************************************** */-
4375-
4376static inline char *-
4377mk_env_string (name, value, isfunc)-
4378 const char *name, *value;-
4379 int isfunc;-
4380{-
4381 size_t name_len, value_len;-
4382 char *p, *q, *t;-
4383-
4384 name_len = strlen (name);-
4385 value_len = STRLEN (value);
(value)[1]Description
TRUEevaluated 4071 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5793 times by 1 test
Evaluated by:
  • Self test
(value)[2]Description
TRUEevaluated 1757 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2314 times by 1 test
Evaluated by:
  • Self test
(value)Description
TRUEevaluated 9908 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[0]Description
TRUEevaluated 9864 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
0-9908
4386-
4387 /* If we are exporting a shell function, construct the encoded function-
4388 name. */-
4389 if (isfunc && value)
isfuncDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9847 times by 1 test
Evaluated by:
  • Self test
valueDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9847
4390 {-
4391 p = (char *)xmalloc (BASHFUNC_PREFLEN + name_len + BASHFUNC_SUFFLEN + value_len + 2);-
4392 q = p;-
4393 memcpy (q, BASHFUNC_PREFIX, BASHFUNC_PREFLEN);-
4394 q += BASHFUNC_PREFLEN;-
4395 memcpy (q, name, name_len);-
4396 q += name_len;-
4397 memcpy (q, BASHFUNC_SUFFIX, BASHFUNC_SUFFLEN);-
4398 q += BASHFUNC_SUFFLEN;-
4399 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
4400 else-
4401 {-
4402 p = (char *)xmalloc (2 + name_len + value_len);-
4403 memcpy (p, name, name_len);-
4404 q = p + name_len;-
4405 }
executed 9847 times by 1 test: end of block
Executed by:
  • Self test
9847
4406-
4407 q[0] = '=';-
4408 if (value && *value)
valueDescription
TRUEevaluated 9908 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*valueDescription
TRUEevaluated 9864 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
0-9908
4409 {-
4410 if (isfunc)
isfuncDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9803 times by 1 test
Evaluated by:
  • Self test
61-9803
4411 {-
4412 t = dequote_escapes (value);-
4413 value_len = STRLEN (t);
(t)[1]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[2]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-61
4414 memcpy (q + 1, t, value_len + 1);-
4415 free (t);-
4416 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
4417 else-
4418 memcpy (q + 1, value, value_len + 1);
executed 9803 times by 1 test: memcpy (q + 1, value, value_len + 1);
Executed by:
  • Self test
9803
4419 }-
4420 else-
4421 q[1] = '\0';
executed 44 times by 1 test: q[1] = '\0';
Executed by:
  • Self test
44
4422-
4423 return (p);
executed 9908 times by 1 test: return (p);
Executed by:
  • Self test
9908
4424}-
4425-
4426#ifdef DEBUG-
4427/* Debugging */-
4428static int-
4429valid_exportstr (v)-
4430 SHELL_VAR *v;-
4431{-
4432 char *s;-
4433-
4434 s = v->exportstr;-
4435 if (s == 0)
s == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4436 {-
4437 internal_error (_("%s has null exportstr"), v->name);-
4438 return (0);
never executed: return (0);
0
4439 }-
4440 if (legal_variable_starter ((unsigned char)*s) == 0)
((1 && ((*__ct... == '_')) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISalpha)Description
TRUEnever evaluated
FALSEnever evaluated
((unsigned char)*s == '_')Description
TRUEnever evaluated
FALSEnever evaluated
0
4441 {-
4442 internal_error (_("invalid character %d in exportstr for %s"), *s, v->name);-
4443 return (0);
never executed: return (0);
0
4444 }-
4445 for (s = v->exportstr + 1; s && *s; s++)
sDescription
TRUEnever evaluated
FALSEnever evaluated
*sDescription
TRUEnever evaluated
FALSEnever evaluated
0
4446 {-
4447 if (*s == '=')
*s == '='Description
TRUEnever evaluated
FALSEnever evaluated
0
4448 break;
never executed: break;
0
4449 if (legal_variable_char ((unsigned char)*s) == 0)
((1 && ((*__ct...s == '_') == 0Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISalnum)Description
TRUEnever evaluated
FALSEnever evaluated
(unsigned char)*s == '_'Description
TRUEnever evaluated
FALSEnever evaluated
0
4450 {-
4451 internal_error (_("invalid character %d in exportstr for %s"), *s, v->name);-
4452 return (0);
never executed: return (0);
0
4453 }-
4454 }
never executed: end of block
0
4455 if (*s != '=')
*s != '='Description
TRUEnever evaluated
FALSEnever evaluated
0
4456 {-
4457 internal_error (_("no `=' in exportstr for %s"), v->name);-
4458 return (0);
never executed: return (0);
0
4459 }-
4460 return (1);
never executed: return (1);
0
4461}-
4462#endif-
4463-
4464static char **-
4465make_env_array_from_var_list (vars)-
4466 SHELL_VAR **vars;-
4467{-
4468 register int i, list_index;-
4469 register SHELL_VAR *var;-
4470 char **list, *value;-
4471-
4472 list = strvec_create ((1 + strvec_len ((char **)vars)));-
4473-
4474#define USE_EXPORTSTR (value == var->exportstr)-
4475-
4476 for (i = 0, list_index = 0; var = vars[i]; i++)
var = vars[i]Description
TRUEevaluated 319958 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18740 times by 1 test
Evaluated by:
  • Self test
18740-319958
4477 {-
4478#if defined (__CYGWIN__)-
4479 /* We don't use the exportstr stuff on Cygwin at all. */-
4480 INVALIDATE_EXPORTSTR (var);-
4481#endif-
4482-
4483 /* If the value is generated dynamically, generate it here. */-
4484 if (regen_p (var) && var->dynamic_value)
((((var)->attr... (0x0040000)))Description
TRUEnever evaluated
FALSEevaluated 319958 times by 1 test
Evaluated by:
  • Self test
var->dynamic_valueDescription
TRUEnever evaluated
FALSEnever evaluated
0-319958
4485 {-
4486 var = (*(var->dynamic_value)) (var);-
4487 INVALIDATE_EXPORTSTR (var);
never executed: end of block
(var)->exportstrDescription
TRUEnever evaluated
FALSEnever evaluated
0
4488 }
never executed: end of block
0
4489-
4490 if (var->exportstr)
var->exportstrDescription
TRUEevaluated 311840 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8118 times by 1 test
Evaluated by:
  • Self test
8118-311840
4491 value = var->exportstr;
executed 311840 times by 1 test: value = var->exportstr;
Executed by:
  • Self test
311840
4492 else if (function_p (var))
((((var)->attr... (0x0000008)))Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8057 times by 1 test
Evaluated by:
  • Self test
61-8057
4493 value = named_function_string ((char *)NULL, function_cell (var), 0);
executed 61 times by 1 test: value = named_function_string ((char *) ((void *)0) , (COMMAND *)((var)->value), 0);
Executed by:
  • Self test
61
4494#if defined (ARRAY_VARS)-
4495 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8049 times by 1 test
Evaluated by:
  • Self test
8-8049
4496# if ARRAY_EXPORT-
4497 value = array_to_assign (array_cell (var), 0);-
4498# else-
4499 continue; /* XXX array vars cannot yet be exported */
executed 8 times by 1 test: continue;
Executed by:
  • Self test
8
4500# endif /* ARRAY_EXPORT */-
4501 else if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 8049 times by 1 test
Evaluated by:
  • Self test
0-8049
4502# if 0-
4503 value = assoc_to_assign (assoc_cell (var), 0);-
4504# else-
4505 continue; /* XXX associative array vars cannot yet be exported */
never executed: continue;
0
4506# endif-
4507#endif-
4508 else-
4509 value = value_cell (var);
executed 8049 times by 1 test: value = ((var)->value);
Executed by:
  • Self test
8049
4510-
4511 if (value)
valueDescription
TRUEevaluated 319923 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-319923
4512 {-
4513 /* Gee, I'd like to get away with not using savestring() if we're-
4514 using the cached exportstr... */-
4515 list[list_index] = USE_EXPORTSTR ? savestring (value)
(value == var->exportstr)Description
TRUEevaluated 311840 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8083 times by 1 test
Evaluated by:
  • Self test
8083-311840
4516 : mk_env_string (var->name, value, function_p (var));-
4517-
4518 if (USE_EXPORTSTR == 0)
(value == var->exportstr) == 0Description
TRUEevaluated 8083 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 311840 times by 1 test
Evaluated by:
  • Self test
8083-311840
4519 SAVE_EXPORTSTR (var, list[list_index]);
executed 8083 times by 1 test: (var)->exportstr = (list[list_index]) ? (char *)strcpy (sh_xmalloc((1 + strlen (list[list_index])), "variables.c", 4519), (list[list_index])) : (char *) ((void *)0) ;
Executed by:
  • Self test
8083
4520-
4521 list_index++;-
4522#undef USE_EXPORTSTR-
4523-
4524#if 0 /* not yet */-
4525#if defined (ARRAY_VARS)-
4526 if (array_p (var) || assoc_p (var))-
4527 free (value);-
4528#endif-
4529#endif-
4530 }
executed 319923 times by 1 test: end of block
Executed by:
  • Self test
319923
4531 }
executed 319950 times by 1 test: end of block
Executed by:
  • Self test
319950
4532-
4533 list[list_index] = (char *)NULL;-
4534 return (list);
executed 18740 times by 1 test: return (list);
Executed by:
  • Self test
18740
4535}-
4536-
4537/* Make an array of assignment statements from the hash table-
4538 HASHED_VARS which contains SHELL_VARs. Only visible, exported-
4539 variables are eligible. */-
4540static char **-
4541make_var_export_array (vcxt)-
4542 VAR_CONTEXT *vcxt;-
4543{-
4544 char **list;-
4545 SHELL_VAR **vars;-
4546-
4547#if 0-
4548 vars = map_over (visible_and_exported, vcxt);-
4549#else-
4550 vars = map_over (export_environment_candidate, vcxt);-
4551#endif-
4552-
4553 if (vars == 0)
vars == 0Description
TRUEnever evaluated
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
0-14159
4554 return (char **)NULL;
never executed: return (char **) ((void *)0) ;
0
4555-
4556 list = make_env_array_from_var_list (vars);-
4557-
4558 free (vars);-
4559 return (list);
executed 14159 times by 1 test: return (list);
Executed by:
  • Self test
14159
4560}-
4561-
4562static char **-
4563make_func_export_array ()-
4564{-
4565 char **list;-
4566 SHELL_VAR **vars;-
4567-
4568 vars = map_over_funcs (visible_and_exported);-
4569 if (vars == 0)
vars == 0Description
TRUEevaluated 9578 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4581 times by 1 test
Evaluated by:
  • Self test
4581-9578
4570 return (char **)NULL;
executed 9578 times by 1 test: return (char **) ((void *)0) ;
Executed by:
  • Self test
9578
4571-
4572 list = make_env_array_from_var_list (vars);-
4573-
4574 free (vars);-
4575 return (list);
executed 4581 times by 1 test: return (list);
Executed by:
  • Self test
4581
4576}-
4577-
4578/* Add ENVSTR to the end of the exported environment, EXPORT_ENV. */-
4579#define add_to_export_env(envstr,do_alloc) \-
4580do \-
4581 { \-
4582 if (export_env_index >= (export_env_size - 1)) \-
4583 { \-
4584 export_env_size += 16; \-
4585 export_env = strvec_resize (export_env, export_env_size); \-
4586 environ = export_env; \-
4587 } \-
4588 export_env[export_env_index++] = (do_alloc) ? savestring (envstr) : envstr; \-
4589 export_env[export_env_index] = (char *)NULL; \-
4590 } while (0)-
4591-
4592/* Add ASSIGN to EXPORT_ENV, or supercede a previous assignment in the-
4593 array with the same left-hand side. Return the new EXPORT_ENV. */-
4594char **-
4595add_or_supercede_exported_var (assign, do_alloc)-
4596 char *assign;-
4597 int do_alloc;-
4598{-
4599 register int i;-
4600 int equal_offset;-
4601-
4602 equal_offset = assignment (assign, 0);-
4603 if (equal_offset == 0)
equal_offset == 0Description
TRUEnever evaluated
FALSEevaluated 27842 times by 1 test
Evaluated by:
  • Self test
0-27842
4604 return (export_env);
never executed: return (export_env);
0
4605-
4606 /* If this is a function, then only supersede the function definition.-
4607 We do this by including the `=() {' in the comparison, like-
4608 initialize_shell_variables does. */-
4609 if (assign[equal_offset + 1] == '(' &&
assign[equal_o...et + 1] == '('Description
TRUEnever evaluated
FALSEevaluated 27842 times by 1 test
Evaluated by:
  • Self test
0-27842
4610 strncmp (assign + equal_offset + 2, ") {", 3) == 0) /* } */
never executed: __result = (((const unsigned char *) (const char *) ( assign + equal_offset + 2 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( ") {" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(__extension__..." , 3 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 3 )Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...l_offset + 2 )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( assig...size_t) ( 3 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( ") {" )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( ") {"...size_t) ( 3 ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4611 equal_offset += 4;
never executed: equal_offset += 4;
0
4612-
4613 for (i = 0; i < export_env_index; i++)
i < export_env_indexDescription
TRUEevaluated 612817 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1856 times by 1 test
Evaluated by:
  • Self test
1856-612817
4614 {-
4615 if (STREQN (assign, export_env[i], equal_offset + 1))
never executed: __result = (((const unsigned char *) (const char *) ( assign ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( export_env[i] ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((equal_offset...+ 1 ))) == 0))Description
TRUEevaluated 25986 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 586831 times by 1 test
Evaluated by:
  • Self test
(equal_offset + 1 == 0)Description
TRUEnever evaluated
FALSEevaluated 612817 times by 1 test
Evaluated by:
  • Self test
(assign)[0] ==...ort_env[i])[0]Description
TRUEevaluated 25986 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 586831 times by 1 test
Evaluated by:
  • Self test
(__extension__...t + 1 ))) == 0Description
TRUEevaluated 25986 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...l_offset + 1 )Description
TRUEnever evaluated
FALSEevaluated 25986 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( assign )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( assig..._offset + 1 ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...xport_env[i] )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( expor..._offset + 1 ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-612817
4616 {-
4617 free (export_env[i]);-
4618 export_env[i] = do_alloc ? savestring (assign) : assign;
do_allocDescription
TRUEnever evaluated
FALSEevaluated 25986 times by 1 test
Evaluated by:
  • Self test
0-25986
4619 return (export_env);
executed 25986 times by 1 test: return (export_env);
Executed by:
  • Self test
25986
4620 }-
4621 }
executed 586831 times by 1 test: end of block
Executed by:
  • Self test
586831
4622 add_to_export_env (assign, do_alloc);
never executed: end of block
export_env_ind..._env_size - 1)Description
TRUEnever evaluated
FALSEevaluated 1856 times by 1 test
Evaluated by:
  • Self test
(do_alloc)Description
TRUEnever evaluated
FALSEevaluated 1856 times by 1 test
Evaluated by:
  • Self test
0-1856
4623 return (export_env);
executed 1856 times by 1 test: return (export_env);
Executed by:
  • Self test
1856
4624}-
4625-
4626static void-
4627add_temp_array_to_env (temp_array, do_alloc, do_supercede)-
4628 char **temp_array;-
4629 int do_alloc, do_supercede;-
4630{-
4631 register int i;-
4632-
4633 if (temp_array == 0)
temp_array == 0Description
TRUEnever evaluated
FALSEevaluated 18740 times by 1 test
Evaluated by:
  • Self test
0-18740
4634 return;
never executed: return;
0
4635-
4636 for (i = 0; temp_array[i]; i++)
temp_array[i]Description
TRUEevaluated 319923 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18740 times by 1 test
Evaluated by:
  • Self test
18740-319923
4637 {-
4638 if (do_supercede)
do_supercedeDescription
TRUEnever evaluated
FALSEevaluated 319923 times by 1 test
Evaluated by:
  • Self test
0-319923
4639 export_env = add_or_supercede_exported_var (temp_array[i], do_alloc);
never executed: export_env = add_or_supercede_exported_var (temp_array[i], do_alloc);
0
4640 else-
4641 add_to_export_env (temp_array[i], do_alloc);
never executed: end of block
executed 319923 times by 1 test: end of block
Executed by:
  • Self test
export_env_ind..._env_size - 1)Description
TRUEnever evaluated
FALSEevaluated 319923 times by 1 test
Evaluated by:
  • Self test
(do_alloc)Description
TRUEnever evaluated
FALSEevaluated 319923 times by 1 test
Evaluated by:
  • Self test
0-319923
4642 }-
4643-
4644 free (temp_array);-
4645}
executed 18740 times by 1 test: end of block
Executed by:
  • Self test
18740
4646-
4647/* Make the environment array for the command about to be executed, if the-
4648 array needs making. Otherwise, do nothing. If a shell action could-
4649 change the array that commands receive for their environment, then the-
4650 code should `array_needs_making++'.-
4651-
4652 The order to add to the array is:-
4653 temporary_env-
4654 list of var contexts whose head is shell_variables-
4655 shell_functions-
4656-
4657 This is the shell variable lookup order. We add only new variable-
4658 names at each step, which allows local variables and variables in-
4659 the temporary environments to shadow variables in the global (or-
4660 any previous) scope.-
4661*/-
4662-
4663static int-
4664n_shell_variables ()-
4665{-
4666 VAR_CONTEXT *vc;-
4667 int n;-
4668-
4669 for (n = 0, vc = shell_variables; vc; vc = vc->down)
vcDescription
TRUEevaluated 18113 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
14159-18113
4670 n += HASH_ENTRIES (vc->table);
executed 18113 times by 1 test: n += ((vc->table) ? (vc->table)->nentries : 0);
Executed by:
  • Self test
(vc->table)Description
TRUEevaluated 15562 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2551 times by 1 test
Evaluated by:
  • Self test
2551-18113
4671 return n;
executed 14159 times by 1 test: return n;
Executed by:
  • Self test
14159
4672}-
4673-
4674int-
4675chkexport (name)-
4676 char *name;-
4677{-
4678 SHELL_VAR *v;-
4679-
4680 v = find_variable (name);-
4681 if (v && exported_p (v))
vDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000001)))Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-18
4682 {-
4683 array_needs_making = 1;-
4684 maybe_make_export_env ();-
4685 return 1;
executed 16 times by 1 test: return 1;
Executed by:
  • Self test
16
4686 }-
4687 return 0;
executed 5 times by 1 test: return 0;
Executed by:
  • Self test
5
4688}-
4689-
4690void-
4691maybe_make_export_env ()-
4692{-
4693 register char **temp_array;-
4694 int new_size;-
4695 VAR_CONTEXT *tcxt;-
4696-
4697 if (array_needs_making)
array_needs_makingDescription
TRUEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3302469 times by 1 test
Evaluated by:
  • Self test
14159-3302469
4698 {-
4699 if (export_env)
export_envDescription
TRUEevaluated 8749 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5410 times by 1 test
Evaluated by:
  • Self test
5410-8749
4700 strvec_flush (export_env);
executed 8749 times by 1 test: strvec_flush (export_env);
Executed by:
  • Self test
8749
4701-
4702 /* Make a guess based on how many shell variables and functions we-
4703 have. Since there will always be array variables, and array-
4704 variables are not (yet) exported, this will always be big enough-
4705 for the exported variables and functions. */-
4706 new_size = n_shell_variables () + HASH_ENTRIES (shell_functions) + 1 +
(shell_functions)Description
TRUEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14159
4707 HASH_ENTRIES (temporary_env);
(temporary_env)Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14063 times by 1 test
Evaluated by:
  • Self test
96-14063
4708 if (new_size > export_env_size)
new_size > export_env_sizeDescription
TRUEevaluated 12489 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1670 times by 1 test
Evaluated by:
  • Self test
1670-12489
4709 {-
4710 export_env_size = new_size;-
4711 export_env = strvec_resize (export_env, export_env_size);-
4712 environ = export_env;-
4713 }
executed 12489 times by 1 test: end of block
Executed by:
  • Self test
12489
4714 export_env[export_env_index = 0] = (char *)NULL;-
4715-
4716 /* Make a dummy variable context from the temporary_env, stick it on-
4717 the front of shell_variables, call make_var_export_array on the-
4718 whole thing to flatten it, and convert the list of SHELL_VAR *s-
4719 to the form needed by the environment. */-
4720 if (temporary_env)
temporary_envDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14063 times by 1 test
Evaluated by:
  • Self test
96-14063
4721 {-
4722 tcxt = new_var_context ((char *)NULL, 0);-
4723 tcxt->table = temporary_env;-
4724 tcxt->down = shell_variables;-
4725 }
executed 96 times by 1 test: end of block
Executed by:
  • Self test
96
4726 else-
4727 tcxt = shell_variables;
executed 14063 times by 1 test: tcxt = shell_variables;
Executed by:
  • Self test
14063
4728 -
4729 temp_array = make_var_export_array (tcxt);-
4730 if (temp_array)
temp_arrayDescription
TRUEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14159
4731 add_temp_array_to_env (temp_array, 0, 0);
executed 14159 times by 1 test: add_temp_array_to_env (temp_array, 0, 0);
Executed by:
  • Self test
14159
4732-
4733 if (tcxt != shell_variables)
tcxt != shell_variablesDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14063 times by 1 test
Evaluated by:
  • Self test
96-14063
4734 free (tcxt);
executed 96 times by 1 test: sh_xfree((tcxt), "variables.c", 4734);
Executed by:
  • Self test
96
4735-
4736#if defined (RESTRICTED_SHELL)-
4737 /* Restricted shells may not export shell functions. */-
4738 temp_array = restricted ? (char **)0 : make_func_export_array ();
restrictedDescription
TRUEnever evaluated
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • Self test
0-14159
4739#else-
4740 temp_array = make_func_export_array ();-
4741#endif-
4742 if (temp_array)
temp_arrayDescription
TRUEevaluated 4581 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9578 times by 1 test
Evaluated by:
  • Self test
4581-9578
4743 add_temp_array_to_env (temp_array, 0, 0);
executed 4581 times by 1 test: add_temp_array_to_env (temp_array, 0, 0);
Executed by:
  • Self test
4581
4744-
4745 array_needs_making = 0;-
4746 }
executed 14159 times by 1 test: end of block
Executed by:
  • Self test
14159
4747}
executed 3316628 times by 1 test: end of block
Executed by:
  • Self test
3316628
4748-
4749/* This is an efficiency hack. PWD and OLDPWD are auto-exported, so-
4750 we will need to remake the exported environment every time we-
4751 change directories. `_' is always put into the environment for-
4752 every external command, so without special treatment it will always-
4753 cause the environment to be remade.-
4754-
4755 If there is no other reason to make the exported environment, we can-
4756 just update the variables in place and mark the exported environment-
4757 as no longer needing a remake. */-
4758void-
4759update_export_env_inplace (env_prefix, preflen, value)-
4760 char *env_prefix;-
4761 int preflen;-
4762 char *value;-
4763{-
4764 char *evar;-
4765-
4766 evar = (char *)xmalloc (STRLEN (value) + preflen + 1);-
4767 strcpy (evar, env_prefix);-
4768 if (value)
valueDescription
TRUEevaluated 27842 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-27842
4769 strcpy (evar + preflen, value);
executed 27842 times by 1 test: strcpy (evar + preflen, value);
Executed by:
  • Self test
27842
4770 export_env = add_or_supercede_exported_var (evar, 0);-
4771}
executed 27842 times by 1 test: end of block
Executed by:
  • Self test
27842
4772-
4773/* We always put _ in the environment as the name of this command. */-
4774void-
4775put_command_name_into_env (command_name)-
4776 char *command_name;-
4777{-
4778 update_export_env_inplace ("_=", 2, command_name);-
4779}
executed 27754 times by 1 test: end of block
Executed by:
  • Self test
27754
4780-
4781/* **************************************************************** */-
4782/* */-
4783/* Managing variable contexts */-
4784/* */-
4785/* **************************************************************** */-
4786-
4787/* Allocate and return a new variable context with NAME and FLAGS.-
4788 NAME can be NULL. */-
4789-
4790VAR_CONTEXT *-
4791new_var_context (name, flags)-
4792 char *name;-
4793 int flags;-
4794{-
4795 VAR_CONTEXT *vc;-
4796-
4797 vc = (VAR_CONTEXT *)xmalloc (sizeof (VAR_CONTEXT));-
4798 vc->name = name ? savestring (name) : (char *)NULL;
nameDescription
TRUEevaluated 1640471 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5630 times by 1 test
Evaluated by:
  • Self test
5630-1640471
4799 vc->scope = variable_context;-
4800 vc->flags = flags;-
4801-
4802 vc->up = vc->down = (VAR_CONTEXT *)NULL;-
4803 vc->table = (HASH_TABLE *)NULL;-
4804-
4805 return vc;
executed 1646101 times by 1 test: return vc;
Executed by:
  • Self test
1646101
4806}-
4807-
4808/* Free a variable context and its data, including the hash table. Dispose-
4809 all of the variables. */-
4810void-
4811dispose_var_context (vc)-
4812 VAR_CONTEXT *vc;-
4813{-
4814 FREE (vc->name);
executed 1636136 times by 1 test: sh_xfree((vc->name), "variables.c", 4814);
Executed by:
  • Self test
vc->nameDescription
TRUEevaluated 1636136 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1636136
4815-
4816 if (vc->table)
vc->tableDescription
TRUEevaluated 323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1635813 times by 1 test
Evaluated by:
  • Self test
323-1635813
4817 {-
4818 delete_all_variables (vc->table);-
4819 hash_dispose (vc->table);-
4820 }
executed 323 times by 1 test: end of block
Executed by:
  • Self test
323
4821-
4822 free (vc);-
4823}
executed 1636136 times by 1 test: end of block
Executed by:
  • Self test
1636136
4824-
4825/* Set VAR's scope level to the current variable context. */-
4826static int-
4827set_context (var)-
4828 SHELL_VAR *var;-
4829{-
4830 return (var->context = variable_context);
executed 177 times by 1 test: return (var->context = variable_context);
Executed by:
  • Self test
177
4831}-
4832-
4833/* Make a new variable context with NAME and FLAGS and a HASH_TABLE of-
4834 temporary variables, and push it onto shell_variables. This is-
4835 for shell functions. */-
4836VAR_CONTEXT *-
4837push_var_context (name, flags, tempvars)-
4838 char *name;-
4839 int flags;-
4840 HASH_TABLE *tempvars;-
4841{-
4842 VAR_CONTEXT *vc;-
4843-
4844 vc = new_var_context (name, flags);-
4845 vc->table = tempvars;-
4846 if (tempvars)
tempvarsDescription
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1640417 times by 1 test
Evaluated by:
  • Self test
156-1640417
4847 {-
4848 /* Have to do this because the temp environment was created before-
4849 variable_context was incremented. */-
4850 flatten (tempvars, set_context, (VARLIST *)NULL, 0);-
4851 vc->flags |= VC_HASTMPVAR;-
4852 }
executed 156 times by 1 test: end of block
Executed by:
  • Self test
156
4853 vc->down = shell_variables;-
4854 shell_variables->up = vc;-
4855-
4856 return (shell_variables = vc);
executed 1640573 times by 1 test: return (shell_variables = vc);
Executed by:
  • Self test
1640573
4857}-
4858-
4859static void-
4860push_func_var (data)-
4861 PTR_T data;-
4862{-
4863 SHELL_VAR *var, *v;-
4864-
4865 var = (SHELL_VAR *)data;-
4866-
4867 if (local_p (var) && STREQ (var->name, "-"))
never executed: __result = (((const unsigned char *) (const char *) ( var->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((((var)->attr... (0x0000020)))Description
TRUEevaluated 526 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 133 times by 1 test
Evaluated by:
  • Self test
(var->name)[0] == ("-")[0]Description
TRUEnever evaluated
FALSEevaluated 526 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-526
4868 set_current_options (value_cell (var));
never executed: set_current_options (((var)->value));
0
4869 else if (tempvar_p (var) && (posixly_correct || (var->attributes & att_propagate)))
((((var)->attr... (0x0100000)))Description
TRUEevaluated 133 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 526 times by 1 test
Evaluated by:
  • Self test
posixly_correctDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 113 times by 1 test
Evaluated by:
  • Self test
(var->attributes & 0x0200000)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110 times by 1 test
Evaluated by:
  • Self test
3-526
4870 {-
4871 /* Make sure we have a hash table to store the variable in while it is-
4872 being propagated down to the global variables table. Create one if-
4873 we have to */-
4874 if ((vc_isfuncenv (shell_variables) || vc_istempenv (shell_variables)) && shell_variables->table == 0)
(((shell_varia... & 0x04) != 0)Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
(((shell_varia...10))) == 0x10)Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
shell_variables->table == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-23
4875 shell_variables->table = hash_create (VARIABLES_HASH_BUCKETS);
never executed: shell_variables->table = hash_create (1024);
0
4876 /* XXX - should we set v->context here? */-
4877 v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0);-
4878#if defined (ARRAY_VARS)-
4879 if (v && (array_p (var) || assoc_p (var)))
vDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000004)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
0-23
4880 {-
4881 FREE (value_cell (v));
never executed: sh_xfree((((v)->value)), "variables.c", 4881);
((v)->value)Description
TRUEnever evaluated
FALSEnever evaluated
0
4882 if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEnever evaluated
FALSEnever evaluated
0
4883 var_setarray (v, array_copy (array_cell (var)));
never executed: ((v)->value = (char *)(array_copy ((ARRAY *)((var)->value))));
0
4884 else-
4885 var_setassoc (v, assoc_copy (assoc_cell (var)));
never executed: ((v)->value = (char *)((hash_copy(((HASH_TABLE *)((var)->value)), 0))));
0
4886 }-
4887#endif -
4888 if (shell_variables == global_variables)
shell_variable...obal_variablesDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-23
4889 var->attributes &= ~(att_tempvar|att_propagate);
executed 23 times by 1 test: var->attributes &= ~(0x0100000|0x0200000);
Executed by:
  • Self test
23
4890 else-
4891 shell_variables->flags |= VC_HASTMPVAR;
never executed: shell_variables->flags |= 0x02;
0
4892 if (v)
vDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-23
4893 v->attributes |= var->attributes;
executed 23 times by 1 test: v->attributes |= var->attributes;
Executed by:
  • Self test
23
4894 }
executed 23 times by 1 test: end of block
Executed by:
  • Self test
23
4895 else-
4896 stupidly_hack_special_variables (var->name); /* XXX */
executed 636 times by 1 test: stupidly_hack_special_variables (var->name);
Executed by:
  • Self test
636
4897-
4898 dispose_variable (var);-
4899}
executed 659 times by 1 test: end of block
Executed by:
  • Self test
659
4900-
4901/* Pop the top context off of VCXT and dispose of it, returning the rest of-
4902 the stack. */-
4903void-
4904pop_var_context ()-
4905{-
4906 VAR_CONTEXT *ret, *vcxt;-
4907-
4908 vcxt = shell_variables;-
4909 if (vc_isfuncenv (vcxt) == 0)
(((vcxt)->flag...04) != 0) == 0Description
TRUEnever evaluated
FALSEevaluated 1636136 times by 1 test
Evaluated by:
  • Self test
0-1636136
4910 {-
4911 internal_error (_("pop_var_context: head of shell_variables not a function context"));-
4912 return;
never executed: return;
0
4913 }-
4914-
4915 if (ret = vcxt->down)
ret = vcxt->downDescription
TRUEevaluated 1636136 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1636136
4916 {-
4917 ret->up = (VAR_CONTEXT *)NULL;-
4918 shell_variables = ret;-
4919 if (vcxt->table)
vcxt->tableDescription
TRUEevaluated 323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1635813 times by 1 test
Evaluated by:
  • Self test
323-1635813
4920 hash_flush (vcxt->table, push_func_var);
executed 323 times by 1 test: hash_flush (vcxt->table, push_func_var);
Executed by:
  • Self test
323
4921 dispose_var_context (vcxt);-
4922 }
executed 1636136 times by 1 test: end of block
Executed by:
  • Self test
1636136
4923 else-
4924 internal_error (_("pop_var_context: no global_variables context"));
never executed: internal_error ( dcgettext (((void *)0), "pop_var_context: no global_variables context" , 5) );
0
4925}-
4926-
4927/* Delete the HASH_TABLEs for all variable contexts beginning at VCXT, and-
4928 all of the VAR_CONTEXTs except GLOBAL_VARIABLES. */-
4929void-
4930delete_all_contexts (vcxt)-
4931 VAR_CONTEXT *vcxt;-
4932{-
4933 VAR_CONTEXT *v, *t;-
4934-
4935 for (v = vcxt; v != global_variables; v = t)
v != global_variablesDescription
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
0-15
4936 {-
4937 t = v->down;-
4938 dispose_var_context (v);-
4939 }
never executed: end of block
0
4940-
4941 delete_all_variables (global_variables->table);-
4942 shell_variables = global_variables;-
4943}
executed 15 times by 1 test: end of block
Executed by:
  • Self test
15
4944-
4945/* **************************************************************** */-
4946/* */-
4947/* Pushing and Popping temporary variable scopes */-
4948/* */-
4949/* **************************************************************** */-
4950-
4951VAR_CONTEXT *-
4952push_scope (flags, tmpvars)-
4953 int flags;-
4954 HASH_TABLE *tmpvars;-
4955{-
4956 return (push_var_context ((char *)NULL, flags, tmpvars));
executed 102 times by 1 test: return (push_var_context ((char *) ((void *)0) , flags, tmpvars));
Executed by:
  • Self test
102
4957}-
4958-
4959static void-
4960push_exported_var (data)-
4961 PTR_T data;-
4962{-
4963 SHELL_VAR *var, *v;-
4964-
4965 var = (SHELL_VAR *)data;-
4966-
4967 /* If a temp var had its export attribute set, or it's marked to be-
4968 propagated, bind it in the previous scope before disposing it. */-
4969 /* XXX - This isn't exactly right, because all tempenv variables have the-
4970 export attribute set. */-
4971#if 0-
4972 if (exported_p (var) || (var->attributes & att_propagate))-
4973#else-
4974 if (tempvar_p (var) && exported_p (var) && (var->attributes & att_propagate))
((((var)->attr... (0x0100000)))Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000001)))Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(var->attributes & 0x0200000)Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
0-42
4975#endif-
4976 {-
4977 var->attributes &= ~att_tempvar; /* XXX */-
4978 v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0);-
4979 if (shell_variables == global_variables)
shell_variable...obal_variablesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4980 var->attributes &= ~att_propagate;
never executed: var->attributes &= ~0x0200000;
0
4981 if (v)
vDescription
TRUEnever evaluated
FALSEnever evaluated
0
4982 v->attributes |= var->attributes;
never executed: v->attributes |= var->attributes;
0
4983 }
never executed: end of block
0
4984 else-
4985 stupidly_hack_special_variables (var->name); /* XXX */
executed 42 times by 1 test: stupidly_hack_special_variables (var->name);
Executed by:
  • Self test
42
4986-
4987 dispose_variable (var);-
4988}
executed 42 times by 1 test: end of block
Executed by:
  • Self test
42
4989-
4990void-
4991pop_scope (is_special)-
4992 int is_special;-
4993{-
4994 VAR_CONTEXT *vcxt, *ret;-
4995-
4996 vcxt = shell_variables;-
4997 if (vc_istempscope (vcxt) == 0)
(((vcxt)->flag...8)) != 0) == 0Description
TRUEnever evaluated
FALSEevaluated 101 times by 1 test
Evaluated by:
  • Self test
0-101
4998 {-
4999 internal_error (_("pop_scope: head of shell_variables not a temporary environment scope"));-
5000 return;
never executed: return;
0
5001 }-
5002-
5003 ret = vcxt->down;-
5004 if (ret)
retDescription
TRUEevaluated 101 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-101
5005 ret->up = (VAR_CONTEXT *)NULL;
executed 101 times by 1 test: ret->up = (VAR_CONTEXT *) ((void *)0) ;
Executed by:
  • Self test
101
5006-
5007 shell_variables = ret;-
5008-
5009 /* Now we can take care of merging variables in VCXT into set of scopes-
5010 whose head is RET (shell_variables). */-
5011 FREE (vcxt->name);
never executed: sh_xfree((vcxt->name), "variables.c", 5011);
vcxt->nameDescription
TRUEnever evaluated
FALSEevaluated 101 times by 1 test
Evaluated by:
  • Self test
0-101
5012 if (vcxt->table)
vcxt->tableDescription
TRUEevaluated 101 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-101
5013 {-
5014 if (is_special)
is_specialDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
42-59
5015 hash_flush (vcxt->table, push_func_var);
executed 59 times by 1 test: hash_flush (vcxt->table, push_func_var);
Executed by:
  • Self test
59
5016 else-
5017 hash_flush (vcxt->table, push_exported_var);
executed 42 times by 1 test: hash_flush (vcxt->table, push_exported_var);
Executed by:
  • Self test
42
5018 hash_dispose (vcxt->table);-
5019 }
executed 101 times by 1 test: end of block
Executed by:
  • Self test
101
5020 free (vcxt);-
5021-
5022 sv_ifs ("IFS"); /* XXX here for now */-
5023}
executed 101 times by 1 test: end of block
Executed by:
  • Self test
101
5024-
5025/* **************************************************************** */-
5026/* */-
5027/* Pushing and Popping function contexts */-
5028/* */-
5029/* **************************************************************** */-
5030-
5031static WORD_LIST **dollar_arg_stack = (WORD_LIST **)NULL;-
5032static int dollar_arg_stack_slots;-
5033static int dollar_arg_stack_index;-
5034-
5035/* XXX - should always be followed by remember_args () */-
5036void-
5037push_context (name, is_subshell, tempvars)-
5038 char *name; /* function name */-
5039 int is_subshell;-
5040 HASH_TABLE *tempvars;-
5041{-
5042 if (is_subshell == 0)
is_subshell == 0Description
TRUEevaluated 1640374 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 97 times by 1 test
Evaluated by:
  • Self test
97-1640374
5043 push_dollar_vars ();
executed 1640374 times by 1 test: push_dollar_vars ();
Executed by:
  • Self test
1640374
5044 variable_context++;-
5045 push_var_context (name, VC_FUNCENV, tempvars);-
5046}
executed 1640471 times by 1 test: end of block
Executed by:
  • Self test
1640471
5047-
5048/* Only called when subshell == 0, so we don't need to check, and can-
5049 unconditionally pop the dollar vars off the stack. */-
5050void-
5051pop_context ()-
5052{-
5053 pop_dollar_vars ();-
5054 variable_context--;-
5055 pop_var_context ();-
5056-
5057 sv_ifs ("IFS"); /* XXX here for now */-
5058}
executed 1636136 times by 1 test: end of block
Executed by:
  • Self test
1636136
5059-
5060/* Save the existing positional parameters on a stack. */-
5061void-
5062push_dollar_vars ()-
5063{-
5064 if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
dollar_arg_sta...rg_stack_slotsDescription
TRUEevaluated 4378 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1637203 times by 1 test
Evaluated by:
  • Self test
4378-1637203
5065 {-
5066 dollar_arg_stack = (WORD_LIST **)-
5067 xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10)-
5068 * sizeof (WORD_LIST *));-
5069 }
executed 4378 times by 1 test: end of block
Executed by:
  • Self test
4378
5070 dollar_arg_stack[dollar_arg_stack_index++] = list_rest_of_args ();-
5071 dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;-
5072}
executed 1641581 times by 1 test: end of block
Executed by:
  • Self test
1641581
5073-
5074/* Restore the positional parameters from our stack. */-
5075void-
5076pop_dollar_vars ()-
5077{-
5078 if (!dollar_arg_stack || dollar_arg_stack_index == 0)
!dollar_arg_stackDescription
TRUEnever evaluated
FALSEevaluated 1637326 times by 1 test
Evaluated by:
  • Self test
dollar_arg_stack_index == 0Description
TRUEnever evaluated
FALSEevaluated 1637326 times by 1 test
Evaluated by:
  • Self test
0-1637326
5079 return;
never executed: return;
0
5080-
5081 remember_args (dollar_arg_stack[--dollar_arg_stack_index], 1);-
5082 dispose_words (dollar_arg_stack[dollar_arg_stack_index]);-
5083 dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;-
5084 set_dollar_vars_unchanged ();-
5085}
executed 1637326 times by 1 test: end of block
Executed by:
  • Self test
1637326
5086-
5087void-
5088dispose_saved_dollar_vars ()-
5089{-
5090 if (!dollar_arg_stack || dollar_arg_stack_index == 0)
!dollar_arg_stackDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
dollar_arg_stack_index == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-7
5091 return;
never executed: return;
0
5092-
5093 dispose_words (dollar_arg_stack[dollar_arg_stack_index]);-
5094 dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;-
5095}
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
5096-
5097/* Initialize BASH_ARGV and BASH_ARGC after turning on extdebug after the-
5098 shell is initialized */-
5099void-
5100init_bash_argv ()-
5101{-
5102 if (bash_argv_initialized == 0)
bash_argv_initialized == 0Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2127 times by 1 test
Evaluated by:
  • Self test
21-2127
5103 {-
5104 save_bash_argv ();-
5105 bash_argv_initialized = 1;-
5106 }
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
5107}
executed 2148 times by 1 test: end of block
Executed by:
  • Self test
2148
5108-
5109void-
5110save_bash_argv ()-
5111{-
5112 WORD_LIST *list;-
5113-
5114 list = list_rest_of_args ();-
5115 push_args (list);-
5116 dispose_words (list);-
5117}
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
5118-
5119/* Manipulate the special BASH_ARGV and BASH_ARGC variables. */-
5120-
5121void-
5122push_args (list)-
5123 WORD_LIST *list;-
5124{-
5125#if defined (ARRAY_VARS) && defined (DEBUGGER)-
5126 SHELL_VAR *bash_argv_v, *bash_argc_v;-
5127 ARRAY *bash_argv_a, *bash_argc_a;-
5128 WORD_LIST *l;-
5129 arrayind_t i;-
5130 char *t;-
5131-
5132 GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);-
5133 GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);-
5134-
5135 for (l = list, i = 0; l; l = l->next, i++)
lDescription
TRUEevaluated 1999 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2148 times by 1 test
Evaluated by:
  • Self test
1999-2148
5136 array_push (bash_argv_a, l->word->word);
executed 1999 times by 1 test: end of block
Executed by:
  • Self test
1999
5137-
5138 t = itos (i);-
5139 array_push (bash_argc_a, t);-
5140 free (t);-
5141#endif /* ARRAY_VARS && DEBUGGER */-
5142}
executed 2148 times by 1 test: end of block
Executed by:
  • Self test
2148
5143-
5144/* Remove arguments from BASH_ARGV array. Pop top element off BASH_ARGC-
5145 array and use that value as the count of elements to remove from-
5146 BASH_ARGV. */-
5147void-
5148pop_args ()-
5149{-
5150#if defined (ARRAY_VARS) && defined (DEBUGGER)-
5151 SHELL_VAR *bash_argv_v, *bash_argc_v;-
5152 ARRAY *bash_argv_a, *bash_argc_a;-
5153 ARRAY_ELEMENT *ce;-
5154 intmax_t i;-
5155-
5156 GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a);-
5157 GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);-
5158-
5159 ce = array_shift (bash_argc_a, 1, 0);-
5160 if (ce == 0 || legal_number (element_value (ce), &i) == 0)
ce == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2251 times by 1 test
Evaluated by:
  • Self test
legal_number (...lue), &i) == 0Description
TRUEnever evaluated
FALSEevaluated 2251 times by 1 test
Evaluated by:
  • Self test
0-2251
5161 i = 0;
executed 15 times by 1 test: i = 0;
Executed by:
  • Self test
15
5162-
5163 for ( ; i > 0; i--)
i > 0Description
TRUEevaluated 2147 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2266 times by 1 test
Evaluated by:
  • Self test
2147-2266
5164 array_pop (bash_argv_a);
executed 2147 times by 1 test: end of block
Executed by:
  • Self test
2147
5165 array_dispose_element (ce);-
5166#endif /* ARRAY_VARS && DEBUGGER */-
5167}
executed 2266 times by 1 test: end of block
Executed by:
  • Self test
2266
5168-
5169/*************************************************-
5170 * *-
5171 * Functions to manage special variables *-
5172 * *-
5173 *************************************************/-
5174-
5175/* Extern declarations for variables this code has to manage. */-
5176-
5177/* An alist of name.function for each special variable. Most of the-
5178 functions don't do much, and in fact, this would be faster with a-
5179 switch statement, but by the end of this file, I am sick of switch-
5180 statements. */-
5181-
5182#define SET_INT_VAR(name, intvar) intvar = find_variable (name) != 0-
5183-
5184/* This table will be sorted with qsort() the first time it's accessed. */-
5185struct name_and_function {-
5186 char *name;-
5187 sh_sv_func_t *function;-
5188};-
5189-
5190static struct name_and_function special_vars[] = {-
5191 { "BASH_COMPAT", sv_shcompat },-
5192 { "BASH_XTRACEFD", sv_xtracefd },-
5193-
5194#if defined (JOB_CONTROL)-
5195 { "CHILD_MAX", sv_childmax },-
5196#endif-
5197-
5198#if defined (READLINE)-
5199# if defined (STRICT_POSIX)-
5200 { "COLUMNS", sv_winsize },-
5201# endif-
5202 { "COMP_WORDBREAKS", sv_comp_wordbreaks },-
5203#endif-
5204-
5205 { "EXECIGNORE", sv_execignore },-
5206-
5207 { "FUNCNEST", sv_funcnest },-
5208-
5209 { "GLOBIGNORE", sv_globignore },-
5210-
5211#if defined (HISTORY)-
5212 { "HISTCONTROL", sv_history_control },-
5213 { "HISTFILESIZE", sv_histsize },-
5214 { "HISTIGNORE", sv_histignore },-
5215 { "HISTSIZE", sv_histsize },-
5216 { "HISTTIMEFORMAT", sv_histtimefmt },-
5217#endif-
5218-
5219#if defined (__CYGWIN__)-
5220 { "HOME", sv_home },-
5221#endif-
5222-
5223#if defined (READLINE)-
5224 { "HOSTFILE", sv_hostfile },-
5225#endif-
5226-
5227 { "IFS", sv_ifs },-
5228 { "IGNOREEOF", sv_ignoreeof },-
5229-
5230 { "LANG", sv_locale },-
5231 { "LC_ALL", sv_locale },-
5232 { "LC_COLLATE", sv_locale },-
5233 { "LC_CTYPE", sv_locale },-
5234 { "LC_MESSAGES", sv_locale },-
5235 { "LC_NUMERIC", sv_locale },-
5236 { "LC_TIME", sv_locale },-
5237-
5238#if defined (READLINE) && defined (STRICT_POSIX)-
5239 { "LINES", sv_winsize },-
5240#endif-
5241-
5242 { "MAIL", sv_mail },-
5243 { "MAILCHECK", sv_mail },-
5244 { "MAILPATH", sv_mail },-
5245-
5246 { "OPTERR", sv_opterr },-
5247 { "OPTIND", sv_optind },-
5248-
5249 { "PATH", sv_path },-
5250 { "POSIXLY_CORRECT", sv_strict_posix },-
5251-
5252#if defined (READLINE)-
5253 { "TERM", sv_terminal },-
5254 { "TERMCAP", sv_terminal },-
5255 { "TERMINFO", sv_terminal },-
5256#endif /* READLINE */-
5257-
5258 { "TEXTDOMAIN", sv_locale },-
5259 { "TEXTDOMAINDIR", sv_locale },-
5260-
5261#if defined (HAVE_TZSET)-
5262 { "TZ", sv_tz },-
5263#endif-
5264-
5265#if defined (HISTORY) && defined (BANG_HISTORY)-
5266 { "histchars", sv_histchars },-
5267#endif /* HISTORY && BANG_HISTORY */-
5268-
5269 { "ignoreeof", sv_ignoreeof },-
5270-
5271 { (char *)0, (sh_sv_func_t *)0 }-
5272};-
5273-
5274#define N_SPECIAL_VARS (sizeof (special_vars) / sizeof (special_vars[0]) - 1)-
5275-
5276static int-
5277sv_compare (sv1, sv2)-
5278 struct name_and_function *sv1, *sv2;-
5279{-
5280 int r;-
5281-
5282 if ((r = sv1->name[0] - sv2->name[0]) == 0)
(r = sv1->name...>name[0]) == 0Description
TRUEevaluated 158560 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 287390 times by 1 test
Evaluated by:
  • Self test
158560-287390
5283 r = strcmp (sv1->name, sv2->name);
executed 158560 times by 1 test: r = __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( sv1->name ) && __builtin_constant_p ( sv2->name ) && (__s1_len = __builtin_strlen ( sv1->name ), __s2_len = __builtin_strlen ( sv2->name ), (!((size_t)(const void *)(( sv1->name ) + 1...nst unsigned char *) (const char *) ( sv2->name ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( sv2->name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( sv1->name , sv2->name )))); }) ;
Executed by:
  • Self test
never executed: __result = (((const unsigned char *) (const char *) ( sv1->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( sv2->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-158560
5284 return r;
executed 445950 times by 1 test: return r;
Executed by:
  • Self test
445950
5285}-
5286-
5287static inline int-
5288find_special_var (name)-
5289 const char *name;-
5290{-
5291 register int i, r;-
5292-
5293 for (i = 0; special_vars[i].name; i++)
special_vars[i].nameDescription
TRUEevaluated 1453190601 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14514246 times by 1 test
Evaluated by:
  • Self test
14514246-1453190601
5294 {-
5295 r = special_vars[i].name[0] - name[0];-
5296 if (r == 0)
r == 0Description
TRUEevaluated 8179628 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1445010973 times by 1 test
Evaluated by:
  • Self test
8179628-1445010973
5297 r = strcmp (special_vars[i].name, name);
executed 8179628 times by 1 test: r = __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( special_vars[i].name ) && __builtin_constant_p ( name ) && (__s1_len = __builtin_strlen ( special_vars[i].name ), __s2_len = __builtin_strlen ( name ), (!((size_t)(const void *)(( spe...((const unsigned char *) (const char *) ( name ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( special_vars[i].name , name )))); }) ;
Executed by:
  • Self test
never executed: __result = (((const unsigned char *) (const char *) ( special_vars[i].name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-8179628
5298 if (r == 0)
r == 0Description
TRUEevaluated 6483382 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1446707219 times by 1 test
Evaluated by:
  • Self test
6483382-1446707219
5299 return i;
executed 6483382 times by 1 test: return i;
Executed by:
  • Self test
6483382
5300 else if (r > 0)
r > 0Description
TRUEevaluated 23963390 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1422743829 times by 1 test
Evaluated by:
  • Self test
23963390-1422743829
5301 /* Can't match any of rest of elements in sorted list. Take this out-
5302 if it causes problems in certain environments. */-
5303 break;
executed 23963390 times by 1 test: break;
Executed by:
  • Self test
23963390
5304 }
executed 1422743829 times by 1 test: end of block
Executed by:
  • Self test
1422743829
5305 return -1;
executed 38477636 times by 1 test: return -1;
Executed by:
  • Self test
38477636
5306}-
5307-
5308/* The variable in NAME has just had its state changed. Check to see if it-
5309 is one of the special ones where something special happens. */-
5310void-
5311stupidly_hack_special_variables (name)-
5312 char *name;-
5313{-
5314 static int sv_sorted = 0;-
5315 int i;-
5316-
5317 if (sv_sorted == 0) /* shouldn't need, but it's fairly cheap. */
sv_sorted == 0Description
TRUEevaluated 4955 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44954432 times by 1 test
Evaluated by:
  • Self test
4955-44954432
5318 {-
5319 qsort (special_vars, N_SPECIAL_VARS, sizeof (special_vars[0]),-
5320 (QSFUNC *)sv_compare);-
5321 sv_sorted = 1;-
5322 }
executed 4955 times by 1 test: end of block
Executed by:
  • Self test
4955
5323-
5324 i = find_special_var (name);-
5325 if (i != -1)
i != -1Description
TRUEevaluated 6481974 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38477413 times by 1 test
Evaluated by:
  • Self test
6481974-38477413
5326 (*(special_vars[i].function)) (name);
executed 6481974 times by 1 test: (*(special_vars[i].function)) (name);
Executed by:
  • Self test
6481974
5327}
executed 44959387 times by 1 test: end of block
Executed by:
  • Self test
44959387
5328-
5329/* Special variables that need hooks to be run when they are unset as part-
5330 of shell reinitialization should have their sv_ functions run here. */-
5331void-
5332reinit_special_variables ()-
5333{-
5334#if defined (READLINE)-
5335 sv_comp_wordbreaks ("COMP_WORDBREAKS");-
5336#endif-
5337 sv_globignore ("GLOBIGNORE");-
5338 sv_opterr ("OPTERR");-
5339}
executed 15 times by 1 test: end of block
Executed by:
  • Self test
15
5340-
5341void-
5342sv_ifs (name)-
5343 char *name;-
5344{-
5345 SHELL_VAR *v;-
5346-
5347 v = find_variable ("IFS");-
5348 setifs (v);-
5349}
executed 9449028 times by 1 test: end of block
Executed by:
  • Self test
9449028
5350-
5351/* What to do just after the PATH variable has changed. */-
5352void-
5353sv_path (name)-
5354 char *name;-
5355{-
5356 /* hash -r */-
5357 phash_flush ();-
5358}
executed 80 times by 1 test: end of block
Executed by:
  • Self test
80
5359-
5360/* What to do just after one of the MAILxxxx variables has changed. NAME-
5361 is the name of the variable. This is called with NAME set to one of-
5362 MAIL, MAILCHECK, or MAILPATH. */-
5363void-
5364sv_mail (name)-
5365 char *name;-
5366{-
5367 /* If the time interval for checking the files has changed, then-
5368 reset the mail timer. Otherwise, one of the pathname vars-
5369 to the users mailbox has changed, so rebuild the array of-
5370 filenames. */-
5371 if (name[4] == 'C') /* if (strcmp (name, "MAILCHECK") == 0) */
name[4] == 'C'Description
TRUEnever evaluated
FALSEnever evaluated
0
5372 reset_mail_timer ();
never executed: reset_mail_timer ();
0
5373 else-
5374 {-
5375 free_mail_files ();-
5376 remember_mail_dates ();-
5377 }
never executed: end of block
0
5378}-
5379-
5380void-
5381sv_funcnest (name)-
5382 char *name;-
5383{-
5384 SHELL_VAR *v;-
5385 intmax_t num;-
5386-
5387 v = find_variable (name);-
5388 if (v == 0)
v == 0Description
TRUEevaluated 5449 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-5449
5389 funcnest_max = 0;
executed 5449 times by 1 test: funcnest_max = 0;
Executed by:
  • Self test
5449
5390 else if (legal_number (value_cell (v), &num) == 0)
legal_number (...e), &num) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
5391 funcnest_max = 0;
never executed: funcnest_max = 0;
0
5392 else-
5393 funcnest_max = num;
executed 3 times by 1 test: funcnest_max = num;
Executed by:
  • Self test
3
5394}-
5395-
5396/* What to do when EXECIGNORE changes. */-
5397void-
5398sv_execignore (name)-
5399 char *name;-
5400{-
5401 setup_exec_ignore (name);-
5402}
never executed: end of block
0
5403-
5404/* What to do when GLOBIGNORE changes. */-
5405void-
5406sv_globignore (name)-
5407 char *name;-
5408{-
5409 if (privileged_mode == 0)
privileged_mode == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-22
5410 setup_glob_ignore (name);
executed 22 times by 1 test: setup_glob_ignore (name);
Executed by:
  • Self test
22
5411}
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
5412-
5413#if defined (READLINE)-
5414void-
5415sv_comp_wordbreaks (name)-
5416 char *name;-
5417{-
5418 SHELL_VAR *sv;-
5419-
5420 sv = find_variable (name);-
5421 if (sv == 0)
sv == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-15
5422 reset_completer_word_break_chars ();
executed 15 times by 1 test: reset_completer_word_break_chars ();
Executed by:
  • Self test
15
5423}
executed 15 times by 1 test: end of block
Executed by:
  • Self test
15
5424-
5425/* What to do just after one of the TERMxxx variables has changed.-
5426 If we are an interactive shell, then try to reset the terminal-
5427 information in readline. */-
5428void-
5429sv_terminal (name)-
5430 char *name;-
5431{-
5432 if (interactive_shell && no_line_editing == 0)
interactive_shellDescription
TRUEnever evaluated
FALSEnever evaluated
no_line_editing == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5433 rl_reset_terminal (get_string_value ("TERM"));
never executed: rl_reset_terminal (get_string_value ("TERM"));
0
5434}
never executed: end of block
0
5435-
5436void-
5437sv_hostfile (name)-
5438 char *name;-
5439{-
5440 SHELL_VAR *v;-
5441-
5442 v = find_variable (name);-
5443 if (v == 0)
v == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5444 clear_hostname_list ();
never executed: clear_hostname_list ();
0
5445 else-
5446 hostname_list_initialized = 0;
never executed: hostname_list_initialized = 0;
0
5447}-
5448-
5449#if defined (STRICT_POSIX)-
5450/* In strict posix mode, we allow assignments to LINES and COLUMNS (and values-
5451 found in the initial environment) to override the terminal size reported by-
5452 the kernel. */-
5453void-
5454sv_winsize (name)-
5455 char *name;-
5456{-
5457 SHELL_VAR *v;-
5458 intmax_t xd;-
5459 int d;-
5460-
5461 if (posixly_correct == 0 || interactive_shell == 0 || no_line_editing)-
5462 return;-
5463-
5464 v = find_variable (name);-
5465 if (v == 0 || var_isset (v) == 0)-
5466 rl_reset_screen_size ();-
5467 else-
5468 {-
5469 if (legal_number (value_cell (v), &xd) == 0)-
5470 return;-
5471 winsize_assignment = 1;-
5472 d = xd; /* truncate */-
5473 if (name[0] == 'L') /* LINES */-
5474 rl_set_screen_size (d, -1);-
5475 else /* COLUMNS */-
5476 rl_set_screen_size (-1, d);-
5477 winsize_assignment = 0;-
5478 }-
5479}-
5480#endif /* STRICT_POSIX */-
5481#endif /* READLINE */-
5482-
5483/* Update the value of HOME in the export environment so tilde expansion will-
5484 work on cygwin. */-
5485#if defined (__CYGWIN__)-
5486sv_home (name)-
5487 char *name;-
5488{-
5489 array_needs_making = 1;-
5490 maybe_make_export_env ();-
5491}-
5492#endif-
5493-
5494#if defined (HISTORY)-
5495/* What to do after the HISTSIZE or HISTFILESIZE variables change.-
5496 If there is a value for this HISTSIZE (and it is numeric), then stifle-
5497 the history. Otherwise, if there is NO value for this variable,-
5498 unstifle the history. If name is HISTFILESIZE, and its value is-
5499 numeric, truncate the history file to hold no more than that many-
5500 lines. */-
5501void-
5502sv_histsize (name)-
5503 char *name;-
5504{-
5505 char *temp;-
5506 intmax_t num;-
5507 int hmax;-
5508-
5509 temp = get_string_value (name);-
5510-
5511 if (temp && *temp)
tempDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
*tempDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-77
5512 {-
5513 if (legal_number (temp, &num))
legal_number (temp, &num)Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-77
5514 {-
5515 hmax = num;-
5516 if (hmax < 0 && name[4] == 'S')
hmax < 0Description
TRUEnever evaluated
FALSEevaluated 77 times by 1 test
Evaluated by:
  • Self test
name[4] == 'S'Description
TRUEnever evaluated
FALSEnever evaluated
0-77
5517 unstifle_history (); /* unstifle history if HISTSIZE < 0 */
never executed: unstifle_history ();
0
5518 else if (name[4] == 'S')
name[4] == 'S'Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-39
5519 {-
5520 stifle_history (hmax);-
5521 hmax = where_history ();-
5522 if (history_lines_this_session > hmax)
history_lines_...session > hmaxDescription
TRUEnever evaluated
FALSEevaluated 39 times by 1 test
Evaluated by:
  • Self test
0-39
5523 history_lines_this_session = hmax;
never executed: history_lines_this_session = hmax;
0
5524 }
executed 39 times by 1 test: end of block
Executed by:
  • Self test
39
5525 else if (hmax >= 0) /* truncate HISTFILE if HISTFILESIZE >= 0 */
hmax >= 0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-38
5526 {-
5527 history_truncate_file (get_string_value ("HISTFILE"), hmax);-
5528 /* If we just shrank the history file to fewer lines than we've-
5529 already read, make sure we adjust our idea of how many lines-
5530 we have read from the file. */-
5531 if (hmax < history_lines_in_file)
hmax < history_lines_in_fileDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
0-38
5532 history_lines_in_file = hmax;
never executed: history_lines_in_file = hmax;
0
5533 }
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
5534 }
executed 77 times by 1 test: end of block
Executed by:
  • Self test
77
5535 }
executed 77 times by 1 test: end of block
Executed by:
  • Self test
77
5536 else if (name[4] == 'S')
name[4] == 'S'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2
5537 unstifle_history ();
executed 2 times by 1 test: unstifle_history ();
Executed by:
  • Self test
2
5538}
executed 81 times by 1 test: end of block
Executed by:
  • Self test
81
5539-
5540/* What to do after the HISTIGNORE variable changes. */-
5541void-
5542sv_histignore (name)-
5543 char *name;-
5544{-
5545 setup_history_ignore (name);-
5546}
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
5547-
5548/* What to do after the HISTCONTROL variable changes. */-
5549void-
5550sv_history_control (name)-
5551 char *name;-
5552{-
5553 char *temp;-
5554 char *val;-
5555 int tptr;-
5556-
5557 history_control = 0;-
5558 temp = get_string_value (name);-
5559-
5560 if (temp == 0 || *temp == 0)
temp == 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
*temp == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
0-33
5561 return;
executed 33 times by 1 test: return;
Executed by:
  • Self test
33
5562-
5563 tptr = 0;-
5564 while (val = extract_colon_unit (temp, &tptr))
val = extract_... (temp, &tptr)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7
5565 {-
5566 if (STREQ (val, "ignorespace"))
never executed: __result = (((const unsigned char *) (const char *) ( val ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ignorespace" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(val)[0] == ("ignorespace")[0]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-7
5567 history_control |= HC_IGNSPACE;
never executed: history_control |= 0x01;
0
5568 else if (STREQ (val, "ignoredups"))
never executed: __result = (((const unsigned char *) (const char *) ( val ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ignoredups" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(val)[0] == ("ignoredups")[0]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-7
5569 history_control |= HC_IGNDUPS;
never executed: history_control |= 0x02;
0
5570 else if (STREQ (val, "ignoreboth"))
never executed: __result = (((const unsigned char *) (const char *) ( val ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ignoreboth" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(val)[0] == ("ignoreboth")[0]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-7
5571 history_control |= HC_IGNBOTH;
executed 7 times by 1 test: history_control |= (0x01|0x02);
Executed by:
  • Self test
7
5572 else if (STREQ (val, "erasedups"))
never executed: __result = (((const unsigned char *) (const char *) ( val ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "erasedups" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(val)[0] == ("erasedups")[0]Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5573 history_control |= HC_ERASEDUPS;
never executed: history_control |= 0x04;
0
5574-
5575 free (val);-
5576 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
5577}
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
5578-
5579#if defined (BANG_HISTORY)-
5580/* Setting/unsetting of the history expansion character. */-
5581void-
5582sv_histchars (name)-
5583 char *name;-
5584{-
5585 char *temp;-
5586-
5587 temp = get_string_value (name);-
5588 if (temp)
tempDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
3-29
5589 {-
5590 history_expansion_char = *temp;-
5591 if (temp[0] && temp[1])
temp[0]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
temp[1]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
5592 {-
5593 history_subst_char = temp[1];-
5594 if (temp[2])
temp[2]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
5595 history_comment_char = temp[2];
executed 3 times by 1 test: history_comment_char = temp[2];
Executed by:
  • Self test
3
5596 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
5597 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
5598 else-
5599 {-
5600 history_expansion_char = '!';-
5601 history_subst_char = '^';-
5602 history_comment_char = '#';-
5603 }
executed 29 times by 1 test: end of block
Executed by:
  • Self test
29
5604}-
5605#endif /* BANG_HISTORY */-
5606-
5607void-
5608sv_histtimefmt (name)-
5609 char *name;-
5610{-
5611 SHELL_VAR *v;-
5612-
5613 if (v = find_variable (name))
v = find_variable (name)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
5614 {-
5615 if (history_comment_char == 0)
history_comment_char == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5616 history_comment_char = '#';
never executed: history_comment_char = '#';
0
5617 }
never executed: end of block
0
5618 history_write_timestamps = (v != 0);-
5619}
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
5620#endif /* HISTORY */-
5621-
5622#if defined (HAVE_TZSET)-
5623void-
5624sv_tz (name)-
5625 char *name;-
5626{-
5627 if (chkexport (name))
chkexport (name)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
5-16
5628 tzset ();
executed 16 times by 1 test: tzset ();
Executed by:
  • Self test
16
5629}
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
5630#endif-
5631-
5632/* If the variable exists, then the value of it can be the number-
5633 of times we actually ignore the EOF. The default is small,-
5634 (smaller than csh, anyway). */-
5635void-
5636sv_ignoreeof (name)-
5637 char *name;-
5638{-
5639 SHELL_VAR *tmp_var;-
5640 char *temp;-
5641-
5642 eof_encountered = 0;-
5643-
5644 tmp_var = find_variable (name);-
5645 ignoreeof = tmp_var && var_isset (tmp_var);
tmp_varDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
((tmp_var)->value != 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-18
5646 temp = tmp_var ? value_cell (tmp_var) : (char *)NULL;
tmp_varDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
3-18
5647 if (temp)
tempDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
3-18
5648 eof_encountered_limit = (*temp && all_digits (temp)) ? atoi (temp) : 10;
executed 3 times by 1 test: eof_encountered_limit = (*temp && all_digits (temp)) ? atoi (temp) : 10;
Executed by:
  • Self test
*tempDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
all_digits (temp)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
5649 set_shellopts (); /* make sure `ignoreeof' is/is not in $SHELLOPTS */-
5650}
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
5651-
5652void-
5653sv_optind (name)-
5654 char *name;-
5655{-
5656 SHELL_VAR *var;-
5657 char *tt;-
5658 int s;-
5659-
5660 var = find_variable ("OPTIND");-
5661 tt = var ? get_variable_value (var) : (char *)NULL;
varDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
5662-
5663 /* Assume that if var->context < variable_context and variable_context > 0-
5664 then we are restoring the variables's previous state while returning-
5665 from a function. */-
5666 if (tt && *tt)
ttDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*ttDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
5667 {-
5668 s = atoi (tt);-
5669-
5670 /* According to POSIX, setting OPTIND=1 resets the internal state-
5671 of getopt (). */-
5672 if (s < 0 || s == 1)
s < 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
s == 1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-8
5673 s = 0;
executed 5 times by 1 test: s = 0;
Executed by:
  • Self test
5
5674 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
5675 else-
5676 s = 0;
never executed: s = 0;
0
5677 getopts_reset (s);-
5678}
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
5679-
5680void-
5681sv_opterr (name)-
5682 char *name;-
5683{-
5684 char *tt;-
5685-
5686 tt = get_string_value ("OPTERR");-
5687 sh_opterr = (tt && *tt) ? atoi (tt) : 1;
ttDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
*ttDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-15
5688}
executed 18 times by 1 test: end of block
Executed by:
  • Self test
18
5689-
5690void-
5691sv_strict_posix (name)-
5692 char *name;-
5693{-
5694 SHELL_VAR *var;-
5695-
5696 var = find_variable (name);-
5697 posixly_correct = var && var_isset (var);
varDescription
TRUEevaluated 162 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 133 times by 1 test
Evaluated by:
  • Self test
((var)->value != 0)Description
TRUEevaluated 162 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-162
5698 posix_initialize (posixly_correct);-
5699#if defined (READLINE)-
5700 if (interactive_shell)
interactive_shellDescription
TRUEnever evaluated
FALSEevaluated 295 times by 1 test
Evaluated by:
  • Self test
0-295
5701 posix_readline_initialize (posixly_correct);
never executed: posix_readline_initialize (posixly_correct);
0
5702#endif /* READLINE */-
5703 set_shellopts (); /* make sure `posix' is/is not in $SHELLOPTS */-
5704}
executed 295 times by 1 test: end of block
Executed by:
  • Self test
295
5705-
5706void-
5707sv_locale (name)-
5708 char *name;-
5709{-
5710 char *v;-
5711 int r;-
5712-
5713 v = get_string_value (name);-
5714 if (name[0] == 'L' && name[1] == 'A') /* LANG */
name[0] == 'L'Description
TRUEevaluated 2997 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
name[1] == 'A'Description
TRUEevaluated 111 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2886 times by 1 test
Evaluated by:
  • Self test
0-2997
5715 r = set_lang (name, v);
executed 111 times by 1 test: r = set_lang (name, v);
Executed by:
  • Self test
111
5716 else-
5717 r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
executed 2886 times by 1 test: r = set_locale_var (name, v);
Executed by:
  • Self test
2886
5718-
5719#if 1-
5720 if (r == 0 && posixly_correct)
r == 0Description
TRUEevaluated 482 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2515 times by 1 test
Evaluated by:
  • Self test
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 482 times by 1 test
Evaluated by:
  • Self test
0-2515
5721 last_command_exit_value = 1;
never executed: last_command_exit_value = 1;
0
5722#endif-
5723}
executed 2997 times by 1 test: end of block
Executed by:
  • Self test
2997
5724-
5725#if defined (ARRAY_VARS)-
5726void-
5727set_pipestatus_array (ps, nproc)-
5728 int *ps;-
5729 int nproc;-
5730{-
5731 SHELL_VAR *v;-
5732 ARRAY *a;-
5733 ARRAY_ELEMENT *ae;-
5734 register int i;-
5735 char *t, tbuf[INT_STRLEN_BOUND(int) + 1];-
5736-
5737 v = find_variable ("PIPESTATUS");-
5738 if (v == 0)
v == 0Description
TRUEevaluated 5414 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71162387 times by 1 test
Evaluated by:
  • Self test
5414-71162387
5739 v = make_new_array_variable ("PIPESTATUS");
executed 5414 times by 1 test: v = make_new_array_variable ("PIPESTATUS");
Executed by:
  • Self test
5414
5740 if (array_p (v) == 0)
((((v)->attrib...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 71167801 times by 1 test
Evaluated by:
  • Self test
0-71167801
5741 return; /* Do nothing if not an array variable. */
never executed: return;
0
5742 a = array_cell (v);-
5743-
5744 if (a == 0 || array_num_elements (a) == 0)
a == 0Description
TRUEnever evaluated
FALSEevaluated 71167801 times by 1 test
Evaluated by:
  • Self test
((a)->num_elements) == 0Description
TRUEevaluated 5414 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71162387 times by 1 test
Evaluated by:
  • Self test
0-71167801
5745 {-
5746 for (i = 0; i < nproc; i++) /* was ps[i] != -1, not i < nproc */
i < nprocDescription
TRUEevaluated 5506 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5414 times by 1 test
Evaluated by:
  • Self test
5414-5506
5747 {-
5748 t = inttostr (ps[i], tbuf, sizeof (tbuf));-
5749 array_insert (a, i, t);-
5750 }
executed 5506 times by 1 test: end of block
Executed by:
  • Self test
5506
5751 return;
executed 5414 times by 1 test: return;
Executed by:
  • Self test
5414
5752 }-
5753-
5754 /* Fast case */-
5755 if (array_num_elements (a) == nproc && nproc == 1)
((a)->num_elements) == nprocDescription
TRUEevaluated 71141128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21259 times by 1 test
Evaluated by:
  • Self test
nproc == 1Description
TRUEevaluated 71140186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 942 times by 1 test
Evaluated by:
  • Self test
942-71141128
5756 {-
5757 ae = element_forw (a->head);-
5758 free (element_value (ae));-
5759 set_element_value (ae, itos (ps[0]));-
5760 }
executed 71140186 times by 1 test: end of block
Executed by:
  • Self test
71140186
5761 else if (array_num_elements (a) <= nproc)
((a)->num_elements) <= nprocDescription
TRUEevaluated 12001 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10200 times by 1 test
Evaluated by:
  • Self test
10200-12001
5762 {-
5763 /* modify in array_num_elements members in place, then add */-
5764 ae = a->head;-
5765 for (i = 0; i < array_num_elements (a); i++)
i < ((a)->num_elements)Description
TRUEevaluated 13115 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12001 times by 1 test
Evaluated by:
  • Self test
12001-13115
5766 {-
5767 ae = element_forw (ae);-
5768 free (element_value (ae));-
5769 set_element_value (ae, itos (ps[i]));-
5770 }
executed 13115 times by 1 test: end of block
Executed by:
  • Self test
13115
5771 /* add any more */-
5772 for ( ; i < nproc; i++)
i < nprocDescription
TRUEevaluated 11175 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12001 times by 1 test
Evaluated by:
  • Self test
11175-12001
5773 {-
5774 t = inttostr (ps[i], tbuf, sizeof (tbuf));-
5775 array_insert (a, i, t);-
5776 }
executed 11175 times by 1 test: end of block
Executed by:
  • Self test
11175
5777 }
executed 12001 times by 1 test: end of block
Executed by:
  • Self test
12001
5778 else-
5779 {-
5780 /* deleting elements. it's faster to rebuild the array. */ -
5781 array_flush (a);-
5782 for (i = 0; ps[i] != -1; i++)
ps[i] != -1Description
TRUEevaluated 10200 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10200 times by 1 test
Evaluated by:
  • Self test
10200
5783 {-
5784 t = inttostr (ps[i], tbuf, sizeof (tbuf));-
5785 array_insert (a, i, t);-
5786 }
executed 10200 times by 1 test: end of block
Executed by:
  • Self test
10200
5787 }
executed 10200 times by 1 test: end of block
Executed by:
  • Self test
10200
5788}-
5789-
5790ARRAY *-
5791save_pipestatus_array ()-
5792{-
5793 SHELL_VAR *v;-
5794 ARRAY *a;-
5795-
5796 v = find_variable ("PIPESTATUS");-
5797 if (v == 0 || array_p (v) == 0 || array_cell (v) == 0)
v == 0Description
TRUEevaluated 1196 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 711019 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 711019 times by 1 test
Evaluated by:
  • Self test
(ARRAY *)((v)->value) == 0Description
TRUEnever evaluated
FALSEevaluated 711019 times by 1 test
Evaluated by:
  • Self test
0-711019
5798 return ((ARRAY *)NULL);
executed 1196 times by 1 test: return ((ARRAY *) ((void *)0) );
Executed by:
  • Self test
1196
5799 -
5800 a = array_copy (array_cell (v));-
5801-
5802 return a;
executed 711019 times by 1 test: return a;
Executed by:
  • Self test
711019
5803}-
5804-
5805void-
5806restore_pipestatus_array (a)-
5807 ARRAY *a;-
5808{-
5809 SHELL_VAR *v;-
5810 ARRAY *a2;-
5811-
5812 v = find_variable ("PIPESTATUS");-
5813 /* XXX - should we still assign even if existing value is NULL? */-
5814 if (v == 0 || array_p (v) == 0 || array_cell (v) == 0)
v == 0Description
TRUEevaluated 1196 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 710987 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 710987 times by 1 test
Evaluated by:
  • Self test
(ARRAY *)((v)->value) == 0Description
TRUEnever evaluated
FALSEevaluated 710987 times by 1 test
Evaluated by:
  • Self test
0-710987
5815 return;
executed 1196 times by 1 test: return;
Executed by:
  • Self test
1196
5816-
5817 a2 = array_cell (v);-
5818 var_setarray (v, a); -
5819-
5820 array_dispose (a2);-
5821}
executed 710987 times by 1 test: end of block
Executed by:
  • Self test
710987
5822#endif-
5823-
5824void-
5825set_pipestatus_from_exit (s)-
5826 int s;-
5827{-
5828#if defined (ARRAY_VARS)-
5829 static int v[2] = { 0, -1 };-
5830-
5831 v[0] = s;-
5832 set_pipestatus_array (v, 1);-
5833#endif-
5834}
executed 71125236 times by 1 test: end of block
Executed by:
  • Self test
71125236
5835-
5836void-
5837sv_xtracefd (name)-
5838 char *name;-
5839{-
5840 SHELL_VAR *v;-
5841 char *t, *e;-
5842 int fd;-
5843 FILE *fp;-
5844-
5845 v = find_variable (name);-
5846 if (v == 0)
v == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-2
5847 {-
5848 xtrace_reset ();-
5849 return;
executed 2 times by 1 test: return;
Executed by:
  • Self test
2
5850 }-
5851-
5852 t = value_cell (v);-
5853 if (t == 0 || *t == 0)
t == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
*t == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
5854 xtrace_reset ();
never executed: xtrace_reset ();
0
5855 else-
5856 {-
5857 fd = (int)strtol (t, &e, 10);-
5858 if (e != t && *e == '\0' && sh_validfd (fd))
e != tDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*e == '\0'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
sh_validfd (fd)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
5859 {-
5860 fp = fdopen (fd, "w");-
5861 if (fp == 0)
fp == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
5862 internal_error (_("%s: %s: cannot open as FILE"), name, value_cell (v));
never executed: internal_error ( dcgettext (((void *)0), "%s: %s: cannot open as FILE" , 5) , name, ((v)->value));
0
5863 else-
5864 xtrace_set (fd, fp);
executed 1 time by 1 test: xtrace_set (fd, fp);
Executed by:
  • Self test
1
5865 }-
5866 else-
5867 internal_error (_("%s: %s: invalid value for trace file descriptor"), name, value_cell (v));
never executed: internal_error ( dcgettext (((void *)0), "%s: %s: invalid value for trace file descriptor" , 5) , name, ((v)->value));
0
5868 }-
5869}-
5870-
5871#define MIN_COMPAT_LEVEL 31-
5872-
5873void-
5874sv_shcompat (name)-
5875 char *name;-
5876{-
5877 SHELL_VAR *v;-
5878 char *val;-
5879 int tens, ones, compatval;-
5880-
5881 v = find_variable (name);-
5882 if (v == 0)
v == 0Description
TRUEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5447
5883 {-
5884 shell_compatibility_level = DEFAULT_COMPAT_LEVEL;-
5885 set_compatibility_opts ();-
5886 return;
executed 5447 times by 1 test: return;
Executed by:
  • Self test
5447
5887 }-
5888 val = value_cell (v);-
5889 if (val == 0 || *val == '\0')
val == 0Description
TRUEnever evaluated
FALSEnever evaluated
*val == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
5890 {-
5891 shell_compatibility_level = DEFAULT_COMPAT_LEVEL;-
5892 set_compatibility_opts ();-
5893 return;
never executed: return;
0
5894 }-
5895 /* Handle decimal-like compatibility version specifications: 4.2 */-
5896 if (ISDIGIT (val[0]) && val[1] == '.' && ISDIGIT (val[2]) && val[3] == 0)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
val[1] == '.'Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
val[3] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5897 {-
5898 tens = val[0] - '0';-
5899 ones = val[2] - '0';-
5900 compatval = tens*10 + ones;-
5901 }
never executed: end of block
0
5902 /* Handle integer-like compatibility version specifications: 42 */-
5903 else if (ISDIGIT (val[0]) && ISDIGIT (val[1]) && val[2] == 0)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
val[2] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5904 {-
5905 tens = val[0] - '0';-
5906 ones = val[1] - '0';-
5907 compatval = tens*10 + ones;-
5908 }
never executed: end of block
0
5909 else-
5910 {-
5911compat_error:-
5912 internal_error (_("%s: %s: compatibility value out of range"), name, val);-
5913 shell_compatibility_level = DEFAULT_COMPAT_LEVEL;-
5914 set_compatibility_opts ();-
5915 return;
never executed: return;
0
5916 }-
5917-
5918 if (compatval < MIN_COMPAT_LEVEL || compatval > DEFAULT_COMPAT_LEVEL)
compatval < 31Description
TRUEnever evaluated
FALSEnever evaluated
compatval > 50Description
TRUEnever evaluated
FALSEnever evaluated
0
5919 goto compat_error;
never executed: goto compat_error;
0
5920-
5921 shell_compatibility_level = compatval;-
5922 set_compatibility_opts ();-
5923}
never executed: end of block
0
5924-
5925#if defined (JOB_CONTROL)-
5926void-
5927sv_childmax (name)-
5928 char *name;-
5929{-
5930 char *tt;-
5931 int s;-
5932-
5933 tt = get_string_value (name);-
5934 s = (tt && *tt) ? atoi (tt) : 0;
ttDescription
TRUEnever evaluated
FALSEnever evaluated
*ttDescription
TRUEnever evaluated
FALSEnever evaluated
0
5935 set_maxchild (s);-
5936}
never executed: end of block
0
5937#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2