]> git.ipfire.org Git - thirdparty/bash.git/blame - shell.h
fix for SIGINT in sourced script
[thirdparty/bash.git] / shell.h
CommitLineData
726f6388
JA
1/* shell.h -- The data structures used by the shell */
2
3185942a 3/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
726f6388
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
3185942a
JA
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.
726f6388 11
3185942a
JA
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.
726f6388 16
3185942a
JA
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*/
726f6388 20
f73dda09 21#ifdef HAVE_CONFIG_H
726f6388 22#include "config.h"
f73dda09 23#endif
ccc6cda3
JA
24
25#include "bashjmp.h"
26
726f6388 27#include "command.h"
28ef6c31 28#include "syntax.h"
726f6388
JA
29#include "general.h"
30#include "error.h"
31#include "variables.h"
f73dda09 32#include "arrayfunc.h"
726f6388
JA
33#include "quit.h"
34#include "maxpath.h"
35#include "unwind_prot.h"
36#include "dispose_cmd.h"
37#include "make_cmd.h"
7117c2d2 38#include "ocache.h"
726f6388 39#include "subst.h"
ccc6cda3
JA
40#include "sig.h"
41#include "pathnames.h"
726f6388
JA
42#include "externs.h"
43
44extern int EOF_Reached;
45
46#define NO_PIPE -1
47#define REDIRECT_BOTH -2
726f6388
JA
48
49#define NO_VARIABLE -1
50
726f6388
JA
51/* Values that can be returned by execute_command (). */
52#define EXECUTION_FAILURE 1
53#define EXECUTION_SUCCESS 0
54
55/* Usage messages by builtins result in a return status of 2. */
ccc6cda3
JA
56#define EX_BADUSAGE 2
57
495aee44
CR
58#define EX_MISCERROR 2
59
ccc6cda3 60/* Special exit statuses used by the shell, internally and externally. */
0001803f
CR
61#define EX_RETRYFAIL 124
62#define EX_WEXPCOMSUB 125
ccc6cda3
JA
63#define EX_BINARY_FILE 126
64#define EX_NOEXEC 126
65#define EX_NOINPUT 126
66#define EX_NOTFOUND 127
726f6388 67
ccc6cda3
JA
68#define EX_SHERRBASE 256 /* all special error values are > this. */
69
70#define EX_BADSYNTAX 257 /* shell syntax error */
71#define EX_USAGE 258 /* syntax error in usage */
72#define EX_REDIRFAIL 259 /* redirection failed */
73#define EX_BADASSIGN 260 /* variable assignment error */
74#define EX_EXPFAIL 261 /* word expansion failed */
726f6388 75
ccc6cda3 76/* Flag values that control parameter pattern substitution. */
b80f6443
JA
77#define MATCH_ANY 0x000
78#define MATCH_BEG 0x001
79#define MATCH_END 0x002
ccc6cda3 80
b80f6443 81#define MATCH_TYPEMASK 0x003
ccc6cda3 82
b80f6443
JA
83#define MATCH_GLOBREP 0x010
84#define MATCH_QUOTED 0x020
a0c0a00f
CR
85#define MATCH_ASSIGNRHS 0x040
86#define MATCH_STARSUB 0x080
726f6388 87
ccc6cda3 88/* Some needed external declarations. */
726f6388
JA
89extern char **shell_environment;
90extern WORD_LIST *rest_of_args;
91
92/* Generalized global variables. */
b80f6443 93extern int debugging_mode;
726f6388 94extern int executing, login_shell;
f73dda09 95extern int interactive, interactive_shell;
7117c2d2 96extern int startup_state;
0001803f 97extern int subshell_environment;
f1be666c 98extern int shell_compatibility_level;
726f6388 99
ac50fbac
CR
100extern int locale_mb_cur_max;
101
726f6388
JA
102/* Structure to pass around that holds a bitmap of file descriptors
103 to close, and the size of that structure. Used in execute_cmd.c. */
104struct fd_bitmap {
f73dda09 105 int size;
726f6388
JA
106 char *bitmap;
107};
108
109#define FD_BITMAP_SIZE 32
110
111#define CTLESC '\001'
112#define CTLNUL '\177'
113
114/* Information about the current user. */
115struct user_info {
d166f048
JA
116 uid_t uid, euid;
117 gid_t gid, egid;
726f6388
JA
118 char *user_name;
119 char *shell; /* shell from the password file */
120 char *home_dir;
121};
122
123extern struct user_info current_user;
f73dda09
JA
124
125/* Force gcc to not clobber X on a longjmp(). Old versions of gcc mangle
126 this badly. */
7117c2d2 127#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 8)
f73dda09
JA
128# define USE_VAR(x) ((void) &(x))
129#else
130# define USE_VAR(x)
131#endif
b80f6443 132
a0c0a00f
CR
133#define HEREDOC_MAX 16
134
b80f6443
JA
135/* Structure in which to save partial parsing state when doing things like
136 PROMPT_COMMAND and bash_execute_unix_command execution. */
137
138typedef struct _sh_parser_state_t {
139
140 /* parsing state */
141 int parser_state;
142 int *token_state;
143
b4839c27
CR
144 char *token;
145 int token_buffer_size;
146
b80f6443
JA
147 /* input line state -- line number saved elsewhere */
148 int input_line_terminator;
149 int eof_encountered;
150
151#if defined (HANDLE_MULTIBYTE)
152 /* Nothing right now for multibyte state, but might want something later. */
153#endif
154
495aee44
CR
155 char **prompt_string_pointer;
156
b80f6443
JA
157 /* history state affecting or modified by the parser */
158 int current_command_line_count;
159#if defined (HISTORY)
160 int remember_on_history;
161 int history_expansion_inhibited;
162#endif
163
164 /* execution state possibly modified by the parser */
165 int last_command_exit_value;
166#if defined (ARRAY_VARS)
167 ARRAY *pipestatus;
168#endif
169 sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
170
171 /* flags state affecting the parser */
172 int expand_aliases;
173 int echo_input_at_read;
daefb2c5 174 int need_here_doc;
a0c0a00f 175 int here_doc_first_line;
daefb2c5 176
a0c0a00f
CR
177 /* structures affecting the parser */
178 REDIRECT *redir_stack[HEREDOC_MAX];
b80f6443
JA
179} sh_parser_state_t;
180
b4839c27
CR
181typedef struct _sh_input_line_state_t {
182 char *input_line;
ac50fbac
CR
183 size_t input_line_index;
184 size_t input_line_size;
185 size_t input_line_len;
b4839c27
CR
186} sh_input_line_state_t;
187
b80f6443 188/* Let's try declaring these here. */
ca6a2ba4
CR
189extern char *parser_remaining_input __P((void));
190
b80f6443
JA
191extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
192extern void restore_parser_state __P((sh_parser_state_t *));
b4839c27
CR
193
194extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *));
195extern void restore_input_line_state __P((sh_input_line_state_t *));