0b1623e58250278e6b011e7daf987dcc940a7c55
[platform/upstream/bash.git] / shell.h
1 /* shell.h -- The data structures used by the shell */
2
3 /* Copyright (C) 1993 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 it under
8    the terms of the GNU General Public License as published by the Free
9    Software Foundation; either version 2, or (at your option) any later
10    version.
11
12    Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13    WARRANTY; without even the implied warranty of MERCHANTABILITY or
14    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15    for more details.
16
17    You should have received a copy of the GNU General Public License along
18    with Bash; see the file COPYING.  If not, write to the Free Software
19    Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #include "config.h"
22
23 #include "bashjmp.h"
24
25 #include "command.h"
26 #include "general.h"
27 #include "error.h"
28 #include "variables.h"
29 #include "quit.h"
30 #include "maxpath.h"
31 #include "unwind_prot.h"
32 #include "dispose_cmd.h"
33 #include "make_cmd.h"
34 #include "subst.h"
35 #include "sig.h"
36 #include "pathnames.h"
37 #include "externs.h"
38
39 extern int EOF_Reached;
40
41 #define NO_PIPE -1
42 #define REDIRECT_BOTH -2
43 #define IS_DESCRIPTOR -1
44
45 #define NO_VARIABLE -1
46
47 /* Values that can be returned by execute_command (). */
48 #define EXECUTION_FAILURE 1
49 #define EXECUTION_SUCCESS 0
50
51 /* Usage messages by builtins result in a return status of 2. */
52 #define EX_BADUSAGE     2
53
54 /* Special exit statuses used by the shell, internally and externally. */
55 #define EX_BINARY_FILE  126
56 #define EX_NOEXEC       126
57 #define EX_NOINPUT      126
58 #define EX_NOTFOUND     127
59
60 #define EX_SHERRBASE    256     /* all special error values are > this. */
61
62 #define EX_BADSYNTAX    257     /* shell syntax error */
63 #define EX_USAGE        258     /* syntax error in usage */
64 #define EX_REDIRFAIL    259     /* redirection failed */
65 #define EX_BADASSIGN    260     /* variable assignment error */
66 #define EX_EXPFAIL      261     /* word expansion failed */
67
68 /* The list of characters that are quoted in double-quotes with a
69    backslash.  Other characters following a backslash cause nothing
70    special to happen. */
71 #define slashify_in_quotes "\\`$\"\n"
72 #define slashify_in_here_document "\\`$"
73
74 /* Constants which specify how to handle backslashes and quoting in
75    expand_word_internal ().  Q_DOUBLE_QUOTES means to use the function
76    slashify_in_quotes () to decide whether the backslash should be
77    retained.  Q_HERE_DOCUMENT means slashify_in_here_document () to
78    decide whether to retain the backslash.  Q_KEEP_BACKSLASH means
79    to unconditionally retain the backslash. */
80 #define Q_DOUBLE_QUOTES  0x1
81 #define Q_HERE_DOCUMENT  0x2
82 #define Q_KEEP_BACKSLASH 0x4
83 #define Q_NOQUOTE        0x8
84 #define Q_QUOTED         0x10
85 #define Q_ADDEDQUOTES    0x20
86 #define Q_QUOTEDNULL     0x40
87
88 /* Flag values that control parameter pattern substitution. */
89 #define MATCH_ANY       0x0
90 #define MATCH_BEG       0x1
91 #define MATCH_END       0x2
92
93 #define MATCH_TYPEMASK  0x3
94
95 #define MATCH_GLOBREP   0x10
96 #define MATCH_QUOTED    0x20
97
98 /* Some needed external declarations. */
99 extern char **shell_environment;
100 extern WORD_LIST *rest_of_args;
101
102 /* Generalized global variables. */
103 extern int executing, login_shell;
104
105 /* Structure to pass around that holds a bitmap of file descriptors
106    to close, and the size of that structure.  Used in execute_cmd.c. */
107 struct fd_bitmap {
108   long size;
109   char *bitmap;
110 };
111
112 #define FD_BITMAP_SIZE 32
113
114 #define CTLESC '\001'
115 #define CTLNUL '\177'
116
117 /* Information about the current user. */
118 struct user_info {
119   int uid, euid;
120   int gid, egid;
121   char *user_name;
122   char *shell;          /* shell from the password file */
123   char *home_dir;
124 };
125
126 extern struct user_info current_user;