Bash  5.0-beta2
Bash - Bourne Again shell
common.c
Go to the documentation of this file.
1 /* common.c - utility functions for all builtins */
2 
3 /* Copyright (C) 1987-2017 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 #if defined (HAVE_UNISTD_H)
24 # ifdef _MINIX
25 # include <sys/types.h>
26 # endif
27 # include <unistd.h>
28 #endif
29 
30 #include <stdio.h>
31 #include <chartypes.h>
32 #include "../bashtypes.h"
33 #include "posixstat.h"
34 #include <signal.h>
35 
36 #include <errno.h>
37 
38 #if defined (PREFER_STDARG)
39 # include <stdarg.h>
40 #else
41 # include <varargs.h>
42 #endif
43 
44 #include "../bashansi.h"
45 #include "../bashintl.h"
46 
47 #define NEED_FPURGE_DECL
48 
49 #include "../shell.h"
50 #include "maxpath.h"
51 #include "../flags.h"
52 #include "../parser.h"
53 #include "../jobs.h"
54 #include "../builtins.h"
55 #include "../input.h"
56 #include "../execute_cmd.h"
57 #include "../trap.h"
58 #include "bashgetopt.h"
59 #include "common.h"
60 #include "builtext.h"
61 #include <tilde/tilde.h>
62 
63 #if defined (HISTORY)
64 # include "../bashhist.h"
65 #endif
66 
67 #if !defined (errno)
68 extern int errno;
69 #endif /* !errno */
70 
71 extern const char * const bash_getcwd_errstr;
72 
73 /* Used by some builtins and the mainline code. */
74 sh_builtin_func_t *last_shell_builtin = (sh_builtin_func_t *)NULL;
75 sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL;
76 
77 /* **************************************************************** */
78 /* */
79 /* Error reporting, usage, and option processing */
80 /* */
81 /* **************************************************************** */
82 
83 /* This is a lot like report_error (), but it is for shell builtins
84  instead of shell control structures, and it won't ever exit the
85  shell. */
86 
87 static void
89 {
90  char *name;
91 
92  name = get_name_for_error ();
93  fprintf (stderr, "%s: ", name);
94 
95  if (interactive_shell == 0)
96  fprintf (stderr, _("line %d: "), executing_line_number ());
97 
99  fprintf (stderr, "%s: ", this_command_name);
100 }
101 
102 void
103 #if defined (PREFER_STDARG)
104 builtin_error (const char *format, ...)
105 #else
106 builtin_error (format, va_alist)
107  const char *format;
108  va_dcl
109 #endif
110 {
111  va_list args;
112 
114 
115  SH_VA_START (args, format);
116 
117  vfprintf (stderr, format, args);
118  va_end (args);
119  fprintf (stderr, "\n");
120 }
121 
122 void
123 #if defined (PREFER_STDARG)
124 builtin_warning (const char *format, ...)
125 #else
126 builtin_warning (format, va_alist)
127  const char *format;
128  va_dcl
129 #endif
130 {
131  va_list args;
132 
134  fprintf (stderr, _("warning: "));
135 
136  SH_VA_START (args, format);
137 
138  vfprintf (stderr, format, args);
139  va_end (args);
140  fprintf (stderr, "\n");
141 }
142 
143 /* Print a usage summary for the currently-executing builtin command. */
144 void
146 {
148  fprintf (stderr, _("%s: usage: "), this_command_name);
149  fprintf (stderr, "%s\n", _(current_builtin->short_doc));
150  fflush (stderr);
151 }
152 
153 /* Return if LIST is NULL else barf and jump to top_level. Used by some
154  builtins that do not accept arguments. */
155 void
157  WORD_LIST *list;
158 {
159  if (list)
160  {
161  builtin_error (_("too many arguments"));
164  }
165 }
166 
167 /* Check that no options were given to the currently-executing builtin,
168  and return 0 if there were options. */
169 int
171  WORD_LIST *list;
172 {
173  int opt;
174 
176  if ((opt = internal_getopt (list, "")) != -1)
177  {
178  if (opt == GETOPT_HELP)
179  {
180  builtin_help ();
181  return (2);
182  }
183  builtin_usage ();
184  return (1);
185  }
186  return (0);
187 }
188 
189 void
191  char *s;
192 {
193  builtin_error (_("%s: option requires an argument"), s);
194 }
195 
196 void
198  char *s;
199 {
200  builtin_error (_("%s: numeric argument required"), s);
201 }
202 
203 void
205  char *s;
206 {
207  builtin_error (_("%s: not found"), s);
208 }
209 
210 /* Function called when one of the builtin commands detects an invalid
211  option. */
212 void
214  char *s;
215 {
216  builtin_error (_("%s: invalid option"), s);
217 }
218 
219 void
221  char *s;
222 {
223  builtin_error (_("%s: invalid option name"), s);
224 }
225 
226 void
228  char *s;
229 {
230  builtin_error (_("`%s': not a valid identifier"), s);
231 }
232 
233 void
235  char *s;
236 {
237  char *msg;
238 
239  if (*s == '0' && isdigit ((unsigned char)s[1]))
240  msg = _("invalid octal number");
241  else if (*s == '0' && s[1] == 'x')
242  msg = _("invalid hex number");
243  else
244  msg = _("invalid number");
245  builtin_error ("%s: %s", s, msg);
246 }
247 
248 void
250  char *s;
251 {
252  builtin_error (_("%s: invalid signal specification"), s);
253 }
254 
255 void
257  char *s;
258 {
259  builtin_error (_("`%s': not a pid or valid job spec"), s);
260 }
261 
262 void
264  const char *s;
265 {
266  builtin_error (_("%s: readonly variable"), s);
267 }
268 
269 void
270 sh_erange (s, desc)
271  char *s, *desc;
272 {
273  if (s)
274  builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument"));
275  else
276  builtin_error (_("%s out of range"), desc ? desc : _("argument"));
277 }
278 
279 #if defined (JOB_CONTROL)
280 void
281 sh_badjob (s)
282  char *s;
283 {
284  builtin_error (_("%s: no such job"), s);
285 }
286 
287 void
288 sh_nojobs (s)
289  char *s;
290 {
291  if (s)
292  builtin_error (_("%s: no job control"), s);
293  else
294  builtin_error (_("no job control"));
295 }
296 #endif
297 
298 #if defined (RESTRICTED_SHELL)
299 void
300 sh_restricted (s)
301  char *s;
302 {
303  if (s)
304  builtin_error (_("%s: restricted"), s);
305  else
306  builtin_error (_("restricted"));
307 }
308 #endif
309 
310 void
312  char *s;
313 {
314  builtin_error (_("%s: not a shell builtin"), s);
315 }
316 
317 void
319 {
320 #if defined (DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS) && defined (EPIPE)
321  if (errno != EPIPE)
322 #endif /* DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS && EPIPE */
323  builtin_error (_("write error: %s"), strerror (errno));
324 }
325 
326 void
328  int set;
329 {
330  if (set)
331  builtin_error (_("error setting terminal attributes: %s"), strerror (errno));
332  else
333  builtin_error (_("error getting terminal attributes: %s"), strerror (errno));
334 }
335 
336 int
338  int s;
339 {
340  QUIT;
341  fflush (stdout);
342  QUIT;
343  if (ferror (stdout))
344  {
345  sh_wrerror ();
346  fpurge (stdout);
347  clearerr (stdout);
348  return (EXECUTION_FAILURE);
349  }
350  return (s);
351 }
352 
353 /* **************************************************************** */
354 /* */
355 /* Shell positional parameter manipulation */
356 /* */
357 /* **************************************************************** */
358 
359 /* Convert a WORD_LIST into a C-style argv. Return the number of elements
360  in the list in *IP, if IP is non-null. A convenience function for
361  loadable builtins; also used by `test'. */
362 char **
364  WORD_LIST *list;
365  int *ip;
366 {
367  char **argv;
368 
369  argv = strvec_from_word_list (list, 0, 1, ip);
370  argv[0] = this_command_name;
371  return argv;
372 }
373 
374 /* Remember LIST in $1 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is
375  non-zero, then discard whatever the existing arguments are, else
376  only discard the ones that are to be replaced. */
377 void
378 remember_args (list, destructive)
379  WORD_LIST *list;
380  int destructive;
381 {
382  register int i;
383 
384  for (i = 1; i < 10; i++)
385  {
386  if ((destructive || list) && dollar_vars[i])
387  {
388  free (dollar_vars[i]);
389  dollar_vars[i] = (char *)NULL;
390  }
391 
392  if (list)
393  {
394  dollar_vars[i] = savestring (list->word->word);
395  list = list->next;
396  }
397  }
398 
399  /* If arguments remain, assign them to REST_OF_ARGS.
400  Note that copy_word_list (NULL) returns NULL, and
401  that dispose_words (NULL) does nothing. */
402  if (destructive || list)
403  {
405  rest_of_args = copy_word_list (list);
406  }
407 
408  if (destructive)
410 
412 }
413 
415 
416 /* Have the dollar variables been reset to new values since we last
417  checked? */
418 int
420 {
421  return (changed_dollar_vars);
422 }
423 
424 void
426 {
428 }
429 
430 void
432 {
433  if (variable_context)
435  else if (this_shell_builtin == set_builtin)
437  else
439 }
440 
441 /* **************************************************************** */
442 /* */
443 /* Validating numeric input and arguments */
444 /* */
445 /* **************************************************************** */
446 
447 /* Read a numeric arg for this_command_name, the name of the shell builtin
448  that wants it. LIST is the word list that the arg is to come from.
449  Accept only the numeric argument; report an error if other arguments
450  follow. If FATAL is 1, call throw_to_top_level, which exits the
451  shell; if it's 2, call jump_to_top_level (DISCARD), which aborts the
452  current command; if FATAL is 0, return an indication of an invalid
453  number by setting *NUMOK == 0 and return -1. */
454 int
455 get_numeric_arg (list, fatal, count)
456  WORD_LIST *list;
457  int fatal;
458  intmax_t *count;
459 {
460  char *arg;
461 
462  if (count)
463  *count = 1;
464 
465  if (list && list->word && ISOPTION (list->word->word, '-'))
466  list = list->next;
467 
468  if (list)
469  {
470  arg = list->word->word;
471  if (arg == 0 || (legal_number (arg, count) == 0))
472  {
473  sh_neednumarg (list->word->word ? list->word->word : "`'");
474  if (fatal == 0)
475  return 0;
476  else if (fatal == 1) /* fatal == 1; abort */
478  else /* fatal == 2; discard current command */
479  {
482  }
483  }
484  no_args (list->next);
485  }
486 
487  return (1);
488 }
489 
490 /* Get an eight-bit status value from LIST */
491 int
493  WORD_LIST *list;
494 {
495  int status;
496  intmax_t sval;
497  char *arg;
498 
499  if (list && list->word && ISOPTION (list->word->word, '-'))
500  list = list->next;
501 
502  if (list == 0)
503  {
504  /* If we're not running the DEBUG trap, the return builtin, when not
505  given any arguments, uses the value of $? before the trap ran. If
506  given an argument, return uses it. This means that the trap can't
507  change $?. The DEBUG trap gets to change $?, though, since that is
508  part of its reason for existing, and because the extended debug mode
509  does things with the return value. */
510  if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1)
511  return (trap_saved_exit_value);
512  return (last_command_exit_value);
513  }
514 
515  arg = list->word->word;
516  if (arg == 0 || legal_number (arg, &sval) == 0)
517  {
518  sh_neednumarg (list->word->word ? list->word->word : "`'");
519  return EX_BADUSAGE;
520  }
521  no_args (list->next);
522 
523  status = sval & 255;
524  return status;
525 }
526 
527 /* Return the octal number parsed from STRING, or -1 to indicate
528  that the string contained a bad number. */
529 int
530 read_octal (string)
531  char *string;
532 {
533  int result, digits;
534 
535  result = digits = 0;
536  while (*string && ISOCTAL (*string))
537  {
538  digits++;
539  result = (result * 8) + (*string++ - '0');
540  if (result > 07777)
541  return -1;
542  }
543 
544  if (digits == 0 || *string)
545  result = -1;
546 
547  return (result);
548 }
549 
550 /* **************************************************************** */
551 /* */
552 /* Manipulating the current working directory */
553 /* */
554 /* **************************************************************** */
555 
556 /* Return a consed string which is the current working directory.
557  FOR_WHOM is the name of the caller for error printing. */
559 
560 char *
562  char *for_whom;
563 {
564  if (no_symbolic_links)
565  {
568  }
569 
571  {
572 #if defined (GETCWD_BROKEN)
574 #else
576 #endif
578  {
579  fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
580  (for_whom && *for_whom) ? for_whom : get_name_for_error (),
582  return (char *)NULL;
583  }
584  }
585 
587 }
588 
589 /* Make NAME our internal idea of the current working directory. */
590 void
592  char *name;
593 {
596 }
597 
598 /* **************************************************************** */
599 /* */
600 /* Job control support functions */
601 /* */
602 /* **************************************************************** */
603 
604 #if defined (JOB_CONTROL)
605 int
606 get_job_by_name (name, flags)
607  const char *name;
608  int flags;
609 {
610  register int i, wl, cl, match, job;
611  register PROCESS *p;
612  register JOB *j;
613 
614  job = NO_JOB;
615  wl = strlen (name);
616  for (i = js.j_jobslots - 1; i >= 0; i--)
617  {
618  j = get_job_by_jid (i);
619  if (j == 0 || ((flags & JM_STOPPED) && J_JOBSTATE(j) != JSTOPPED))
620  continue;
621 
622  p = j->pipe;
623  do
624  {
625  if (flags & JM_EXACT)
626  {
627  cl = strlen (p->command);
628  match = STREQN (p->command, name, cl);
629  }
630  else if (flags & JM_SUBSTRING)
631  match = strcasestr (p->command, name) != (char *)0;
632  else
633  match = STREQN (p->command, name, wl);
634 
635  if (match == 0)
636  {
637  p = p->next;
638  continue;
639  }
640  else if (flags & JM_FIRSTMATCH)
641  return i; /* return first match */
642  else if (job != NO_JOB)
643  {
644  if (this_shell_builtin)
645  builtin_error (_("%s: ambiguous job spec"), name);
646  else
647  internal_error (_("%s: ambiguous job spec"), name);
648  return (DUP_JOB);
649  }
650  else
651  job = i;
652  }
653  while (p != j->pipe);
654  }
655 
656  return (job);
657 }
658 
659 /* Return the job spec found in LIST. */
660 int
661 get_job_spec (list)
662  WORD_LIST *list;
663 {
664  register char *word;
665  int job, jflags;
666 
667  if (list == 0)
668  return (js.j_current);
669 
670  word = list->word->word;
671 
672  if (*word == '\0')
673  return (NO_JOB);
674 
675  if (*word == '%')
676  word++;
677 
678  if (DIGIT (*word) && all_digits (word))
679  {
680  job = atoi (word);
681  return ((job < 0 || job > js.j_jobslots) ? NO_JOB : job - 1);
682  }
683 
684  jflags = 0;
685  switch (*word)
686  {
687  case 0:
688  case '%':
689  case '+':
690  return (js.j_current);
691 
692  case '-':
693  return (js.j_previous);
694 
695  case '?': /* Substring search requested. */
696  jflags |= JM_SUBSTRING;
697  word++;
698  /* FALLTHROUGH */
699 
700  default:
701  return get_job_by_name (word, jflags);
702  }
703 }
704 #endif /* JOB_CONTROL */
705 
706 /*
707  * NOTE: `kill' calls this function with forcecols == 0
708  */
709 int
710 display_signal_list (list, forcecols)
711  WORD_LIST *list;
712  int forcecols;
713 {
714  register int i, column;
715  char *name;
716  int result, signum, dflags;
717  intmax_t lsignum;
718 
719  result = EXECUTION_SUCCESS;
720  if (!list)
721  {
722  for (i = 1, column = 0; i < NSIG; i++)
723  {
724  name = signal_name (i);
725  if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
726  continue;
727 
728  if (posixly_correct && !forcecols)
729  {
730  /* This is for the kill builtin. POSIX.2 says the signal names
731  are displayed without the `SIG' prefix. */
732  if (STREQN (name, "SIG", 3))
733  name += 3;
734  printf ("%s%s", name, (i == NSIG - 1) ? "" : " ");
735  }
736  else
737  {
738  printf ("%2d) %s", i, name);
739 
740  if (++column < 5)
741  printf ("\t");
742  else
743  {
744  printf ("\n");
745  column = 0;
746  }
747  }
748  }
749 
750  if ((posixly_correct && !forcecols) || column != 0)
751  printf ("\n");
752  return result;
753  }
754 
755  /* List individual signal names or numbers. */
756  while (list)
757  {
758  if (legal_number (list->word->word, &lsignum))
759  {
760  /* This is specified by Posix.2 so that exit statuses can be
761  mapped into signal numbers. */
762  if (lsignum > 128)
763  lsignum -= 128;
764  if (lsignum < 0 || lsignum >= NSIG)
765  {
766  sh_invalidsig (list->word->word);
767  result = EXECUTION_FAILURE;
768  list = list->next;
769  continue;
770  }
771 
772  signum = lsignum;
773  name = signal_name (signum);
774  if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7))
775  {
776  list = list->next;
777  continue;
778  }
779  /* POSIX.2 says that `kill -l signum' prints the signal name without
780  the `SIG' prefix. */
781  printf ("%s\n", (this_shell_builtin == kill_builtin && signum > 0) ? name + 3 : name);
782  }
783  else
784  {
785  dflags = DSIG_NOCASE;
786  if (posixly_correct == 0 || this_shell_builtin != kill_builtin)
787  dflags |= DSIG_SIGPREFIX;
788  signum = decode_signal (list->word->word, dflags);
789  if (signum == NO_SIG)
790  {
791  sh_invalidsig (list->word->word);
792  result = EXECUTION_FAILURE;
793  list = list->next;
794  continue;
795  }
796  printf ("%d\n", signum);
797  }
798  list = list->next;
799  }
800  return (result);
801 }
802 
803 /* **************************************************************** */
804 /* */
805 /* Finding builtin commands and their functions */
806 /* */
807 /* **************************************************************** */
808 
809 /* Perform a binary search and return the address of the builtin function
810  whose name is NAME. If the function couldn't be found, or the builtin
811  is disabled or has no function associated with it, return NULL.
812  Return the address of the builtin.
813  DISABLED_OKAY means find it even if the builtin is disabled. */
814 struct builtin *
816  char *name;
817  int disabled_okay;
818 {
819  int hi, lo, mid, j;
820 
821  hi = num_shell_builtins - 1;
822  lo = 0;
823 
824  while (lo <= hi)
825  {
826  mid = (lo + hi) / 2;
827 
828  j = shell_builtins[mid].name[0] - name[0];
829 
830  if (j == 0)
831  j = strcmp (shell_builtins[mid].name, name);
832 
833  if (j == 0)
834  {
835  /* It must have a function pointer. It must be enabled, or we
836  must have explicitly allowed disabled functions to be found,
837  and it must not have been deleted. */
838  if (shell_builtins[mid].function &&
839  ((shell_builtins[mid].flags & BUILTIN_DELETED) == 0) &&
840  ((shell_builtins[mid].flags & BUILTIN_ENABLED) || disabled_okay))
841  return (&shell_builtins[mid]);
842  else
843  return ((struct builtin *)NULL);
844  }
845  if (j > 0)
846  hi = mid - 1;
847  else
848  lo = mid + 1;
849  }
850  return ((struct builtin *)NULL);
851 }
852 
853 /* Return the pointer to the function implementing builtin command NAME. */
854 sh_builtin_func_t *
856  char *name;
857 {
859  return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL);
860 }
861 
862 /* Return the address of builtin with NAME, whether it is enabled or not. */
863 sh_builtin_func_t *
865  char *name;
866 {
868  return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL);
869 }
870 
871 /* Return the function implementing the builtin NAME, but only if it is a
872  POSIX.2 special builtin. */
873 sh_builtin_func_t *
875  char *name;
876 {
880  (sh_builtin_func_t *)NULL);
881 }
882 
883 static int
885  struct builtin *sbp1, *sbp2;
886 {
887  int result;
888 
889  if ((result = sbp1->name[0] - sbp2->name[0]) == 0)
890  result = strcmp (sbp1->name, sbp2->name);
891 
892  return (result);
893 }
894 
895 /* Sort the table of shell builtins so that the binary search will work
896  in find_shell_builtin. */
897 void
899 {
900  qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
902 }
903 
904 #if !defined (HELP_BUILTIN)
905 void
907 {
908  printf ("%s: %s\n", this_command_name, _("help not available in this version"));
909 }
910 #endif
void sh_invalidopt(char *s)
Definition: common.c:213
#define GETOPT_HELP
Definition: bashgetopt.h:29
#define get_job_by_jid(ind)
Definition: jobs.h:86
void sh_neednumarg(char *s)
Definition: common.c:197
void top_level_cleanup()
Definition: sig.c:372
int interactive_shell
Definition: shell.c:140
int sh_chkwrite(int s)
Definition: common.c:337
#define DSIG_NOCASE
Definition: trap.h:50
sh_builtin_func_t * function
Definition: builtins.h:54
static char ** argv
Definition: test.c:110
#define QUIT
Definition: quit.h:35
void sh_invalidid(char *s)
Definition: common.c:227
char * strcasestr(char *s1, const char *s2) const
Definition: strcasestr.c:33
static int changed_dollar_vars
Definition: common.c:414
#define NO_JOB
Definition: jobs.h:172
int no_options(WORD_LIST *list)
Definition: common.c:170
#define DSIG_SIGPREFIX
Definition: trap.h:49
int j_jobslots
Definition: jobs.h:137
list
Definition: subst.c:10212
sh_builtin_func_t * find_special_builtin(char *name)
Definition: common.c:874
#define JM_EXACT
Definition: common.h:69
void sh_invalidsig(char *s)
Definition: common.c:249
char * strerror()
#define NSIG
Definition: mksignames.c:36
const char * short_doc
Definition: builtins.h:57
WORD_LIST * copy_word_list(WORD_LIST *list)
Definition: copy_cmd.c:69
tword word
Definition: subst.c:10420
int CHAR * string
Definition: gm_loop.c:46
void sh_needarg(char *s)
Definition: common.c:190
#define DISCARD
Definition: bashjmp.h:41
#define EX_BADUSAGE
Definition: shell.h:56
char * this_command_name
Definition: execute_cmd.c:202
#define JM_STOPPED
Definition: common.h:70
void no_args(WORD_LIST *list)
Definition: common.c:156
char * command
Definition: jobs.h:65
#define ISOCTAL(c)
Definition: mkdir.c:43
#define ARGS_SETBLTIN
Definition: common.h:77
void throw_to_top_level()
Definition: sig.c:389
int posixly_correct
Definition: shell.c:232
char * word
Definition: command.h:127
static void builtin_error_prolog()
Definition: common.c:88
int no_symbolic_links
Definition: flags.c:102
#define DEBUG_TRAP
Definition: trap.h:40
int executing_line_number()
Definition: execute_cmd.c:349
#define J_JOBSTATE(j)
Definition: jobs.h:91
static nls_uint32 nls_uint32 i
Definition: gettextP.h:74
int num_shell_builtins
void set_dollar_vars_unchanged()
Definition: common.c:425
void jump_to_top_level(int value)
Definition: sig.c:461
int atoi()
Definition: jobs.h:60
#define DIGIT(c)
Definition: chartypes.h:83
p
Definition: glob_loop.c:31
void set_dollar_vars_changed()
Definition: common.c:431
void builtin_error(char *format, va_alist) const
Definition: common.c:106
int running_trap
Definition: trap.c:113
void sh_notbuiltin(char *s)
Definition: common.c:311
void builtin_warning(char *format, va_alist) const
Definition: common.c:126
void builtin_usage()
Definition: common.c:145
int decode_signal(char *string, int flags)
Definition: trap.c:227
Definition: jobs.h:89
int read_octal(char *string)
Definition: common.c:530
char * savestring(const char *s)
Definition: savestring.c:33
void xs_init _((void))
void builtin_help()
Definition: common.c:906
#define PATH_MAX
Definition: maxpath.h:63
int dollar_vars_changed()
Definition: common.c:419
#define BUILTIN_ENABLED
Definition: builtins.h:41
Definition: jobs.h:113
#define DUP_JOB
Definition: jobs.h:173
void sh_ttyerror(int set)
Definition: common.c:327
#define EXECUTION_SUCCESS
Definition: shell.h:53
WORD_DESC * word
Definition: command.h:134
void free()
int QSFUNC()
Definition: general.h:266
void sh_invalidnum(char *s)
Definition: common.c:234
int flags
Definition: builtins.h:55
void dispose_words(WORD_LIST *list)
Definition: dispose_cmd.c:264
#define STREQN(a, b, n)
Definition: general.h:167
int trap_saved_exit_value
Definition: trap.c:116
int get_exitstat(WORD_LIST *list)
Definition: common.c:492
struct builtin * shell_builtins
int variable_context
Definition: variables.c:123
void reset_internal_getopt()
Definition: bashgetopt.c:177
char * dollar_vars[10]
Definition: variables.c:144
char * getcwd(char *buf, size_t size)
Definition: getcwd.c:110
char * get_working_directory(char *for_whom)
Definition: common.c:561
int get_numeric_arg(WORD_LIST *list, int fatal, intmax_t *count)
Definition: common.c:455
PROCESS * pipe
Definition: jobs.h:115
#define JM_SUBSTRING
Definition: common.h:68
#define BUILTIN_DELETED
Definition: builtins.h:42
#define NULL
Definition: general.h:53
void internal_error(char *format, va_alist) const
Definition: error.c:235
void qsort()
char * get_name_for_error()
Definition: error.c:96
sh_builtin_func_t * this_shell_builtin
Definition: common.c:75
struct jobstats js
Definition: jobs.c:176
#define SH_VA_START(va, arg)
Definition: stdc.h:96
#define ARGS_INVOC
Definition: common.h:75
#define EXECUTION_FAILURE
Definition: shell.h:52
#define FREE(s)
Definition: general.h:172
int j_current
Definition: jobs.h:143
int flags
Definition: gm_loop.c:47
sh_builtin_func_t * last_shell_builtin
Definition: common.c:74
int internal_getopt(WORD_LIST *list, char *opts)
Definition: bashgetopt.c:50
void set_working_directory(char *name)
Definition: common.c:591
struct builtin * builtin_address_internal(char *name, int disabled_okay)
Definition: common.c:815
static int shell_builtin_compare(struct builtin *sbp1, struct builtin *sbp2)
Definition: common.c:884
sh_builtin_func_t * find_shell_builtin(char *name)
Definition: common.c:855
#define SPECIAL_BUILTIN
Definition: builtins.h:44
void invalidate_cached_quoted_dollar_at()
Definition: subst.c:9641
char ** make_builtin_argv(WORD_LIST *list, int *ip)
Definition: common.c:363
int display_signal_list(WORD_LIST *list, int forcecols)
Definition: common.c:710
char * name
Definition: builtins.h:53
#define NO_SIG
Definition: trap.h:35
#define JM_FIRSTMATCH
Definition: common.h:71
int last_command_exit_value
Definition: execute_cmd.c:215
const char *const bash_getcwd_errstr
Definition: general.c:69
int fpurge(FILE *fp)
Definition: fpurge.c:124
#define ARGS_FUNC
Definition: common.h:76
struct process * next
Definition: jobs.h:61
sh_builtin_func_t * builtin_address(char *name)
Definition: common.c:864
#define ISOPTION(s, c)
Definition: common.h:26
void sh_readonly(char *s) const
Definition: common.c:263
void sh_notfound(char *s)
Definition: common.c:204
void remember_args(WORD_LIST *list, int destructive)
Definition: common.c:378
struct builtin * current_builtin
char * signal_name(int sig)
Definition: trap.c:209
void sh_erange(char *s, char *desc)
Definition: common.c:270
void initialize_shell_builtins()
Definition: common.c:898
int errno
char ** strvec_from_word_list(WORD_LIST *list, int alloc, int starting_index, int *ip)
Definition: stringvec.c:196
void sh_invalidoptname(char *s)
Definition: common.c:220
int legal_number(char *string, intmax_t *result) const
Definition: general.c:175
int j_previous
Definition: jobs.h:144
void sh_badpid(char *s)
Definition: common.c:256
struct word_list * next
Definition: command.h:133
void sh_wrerror()
Definition: common.c:318
char * the_current_working_directory
Definition: common.c:558
int all_digits(char *string) const
Definition: general.c:159
WORD_LIST * rest_of_args
Definition: variables.c:145