1 /* shell.h -- The data structures used by the shell */
3 /* Copyright (C) 1993-2002 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
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
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
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, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
31 #include "variables.h"
32 #include "arrayfunc.h"
35 #include "unwind_prot.h"
36 #include "dispose_cmd.h"
41 #include "pathnames.h"
44 extern int EOF_Reached
;
47 #define REDIRECT_BOTH -2
49 #define NO_VARIABLE -1
51 /* Values that can be returned by execute_command (). */
52 #define EXECUTION_FAILURE 1
53 #define EXECUTION_SUCCESS 0
55 /* Usage messages by builtins result in a return status of 2. */
58 /* Special exit statuses used by the shell, internally and externally. */
59 #define EX_BINARY_FILE 126
61 #define EX_NOINPUT 126
62 #define EX_NOTFOUND 127
64 #define EX_SHERRBASE 256 /* all special error values are > this. */
66 #define EX_BADSYNTAX 257 /* shell syntax error */
67 #define EX_USAGE 258 /* syntax error in usage */
68 #define EX_REDIRFAIL 259 /* redirection failed */
69 #define EX_BADASSIGN 260 /* variable assignment error */
70 #define EX_EXPFAIL 261 /* word expansion failed */
72 /* Flag values that control parameter pattern substitution. */
73 #define MATCH_ANY 0x000
74 #define MATCH_BEG 0x001
75 #define MATCH_END 0x002
77 #define MATCH_TYPEMASK 0x003
79 #define MATCH_GLOBREP 0x010
80 #define MATCH_QUOTED 0x020
81 #define MATCH_STARSUB 0x040
83 /* Some needed external declarations. */
84 extern char **shell_environment
;
85 extern WORD_LIST
*rest_of_args
;
87 /* Generalized global variables. */
88 extern int debugging_mode
;
89 extern int executing
, login_shell
;
90 extern int interactive
, interactive_shell
;
91 extern int startup_state
;
92 extern int shell_compatibility_level
;
94 /* Structure to pass around that holds a bitmap of file descriptors
95 to close, and the size of that structure. Used in execute_cmd.c. */
101 #define FD_BITMAP_SIZE 32
103 #define CTLESC '\001'
104 #define CTLNUL '\177'
106 /* Information about the current user. */
111 char *shell
; /* shell from the password file */
115 extern struct user_info current_user
;
117 /* Force gcc to not clobber X on a longjmp(). Old versions of gcc mangle
119 #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 8)
120 # define USE_VAR(x) ((void) &(x))
125 /* Structure in which to save partial parsing state when doing things like
126 PROMPT_COMMAND and bash_execute_unix_command execution. */
128 typedef struct _sh_parser_state_t
{
134 /* input line state -- line number saved elsewhere */
135 int input_line_terminator
;
138 #if defined (HANDLE_MULTIBYTE)
139 /* Nothing right now for multibyte state, but might want something later. */
142 /* history state affecting or modified by the parser */
143 int current_command_line_count
;
144 #if defined (HISTORY)
145 int remember_on_history
;
146 int history_expansion_inhibited
;
149 /* execution state possibly modified by the parser */
150 int last_command_exit_value
;
151 #if defined (ARRAY_VARS)
154 sh_builtin_func_t
*last_shell_builtin
, *this_shell_builtin
;
156 /* flags state affecting the parser */
158 int echo_input_at_read
;
162 /* Let's try declaring these here. */
163 extern sh_parser_state_t
*save_parser_state
__P((sh_parser_state_t
*));
164 extern void restore_parser_state
__P((sh_parser_state_t
*));