]> git.ipfire.org Git - thirdparty/bash.git/blame - shell.h
Imported from ../bash-3.2.tar.gz.
[thirdparty/bash.git] / shell.h
CommitLineData
726f6388
JA
1/* shell.h -- The data structures used by the shell */
2
b80f6443 3/* Copyright (C) 1993-2002 Free Software Foundation, Inc.
726f6388
JA
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
bb70624e 19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
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
58/* Special exit statuses used by the shell, internally and externally. */
59#define EX_BINARY_FILE 126
60#define EX_NOEXEC 126
61#define EX_NOINPUT 126
62#define EX_NOTFOUND 127
726f6388 63
ccc6cda3
JA
64#define EX_SHERRBASE 256 /* all special error values are > this. */
65
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 */
726f6388 71
ccc6cda3 72/* Flag values that control parameter pattern substitution. */
b80f6443
JA
73#define MATCH_ANY 0x000
74#define MATCH_BEG 0x001
75#define MATCH_END 0x002
ccc6cda3 76
b80f6443 77#define MATCH_TYPEMASK 0x003
ccc6cda3 78
b80f6443
JA
79#define MATCH_GLOBREP 0x010
80#define MATCH_QUOTED 0x020
81#define MATCH_STARSUB 0x040
726f6388 82
ccc6cda3 83/* Some needed external declarations. */
726f6388
JA
84extern char **shell_environment;
85extern WORD_LIST *rest_of_args;
86
87/* Generalized global variables. */
b80f6443 88extern int debugging_mode;
726f6388 89extern int executing, login_shell;
f73dda09 90extern int interactive, interactive_shell;
7117c2d2 91extern int startup_state;
726f6388
JA
92
93/* Structure to pass around that holds a bitmap of file descriptors
94 to close, and the size of that structure. Used in execute_cmd.c. */
95struct fd_bitmap {
f73dda09 96 int size;
726f6388
JA
97 char *bitmap;
98};
99
100#define FD_BITMAP_SIZE 32
101
102#define CTLESC '\001'
103#define CTLNUL '\177'
104
105/* Information about the current user. */
106struct user_info {
d166f048
JA
107 uid_t uid, euid;
108 gid_t gid, egid;
726f6388
JA
109 char *user_name;
110 char *shell; /* shell from the password file */
111 char *home_dir;
112};
113
114extern struct user_info current_user;
f73dda09
JA
115
116/* Force gcc to not clobber X on a longjmp(). Old versions of gcc mangle
117 this badly. */
7117c2d2 118#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 8)
f73dda09
JA
119# define USE_VAR(x) ((void) &(x))
120#else
121# define USE_VAR(x)
122#endif
b80f6443
JA
123
124/* Structure in which to save partial parsing state when doing things like
125 PROMPT_COMMAND and bash_execute_unix_command execution. */
126
127typedef struct _sh_parser_state_t {
128
129 /* parsing state */
130 int parser_state;
131 int *token_state;
132
133 /* input line state -- line number saved elsewhere */
134 int input_line_terminator;
135 int eof_encountered;
136
137#if defined (HANDLE_MULTIBYTE)
138 /* Nothing right now for multibyte state, but might want something later. */
139#endif
140
141 /* history state affecting or modified by the parser */
142 int current_command_line_count;
143#if defined (HISTORY)
144 int remember_on_history;
145 int history_expansion_inhibited;
146#endif
147
148 /* execution state possibly modified by the parser */
149 int last_command_exit_value;
150#if defined (ARRAY_VARS)
151 ARRAY *pipestatus;
152#endif
153 sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
154
155 /* flags state affecting the parser */
156 int expand_aliases;
157 int echo_input_at_read;
158
159} sh_parser_state_t;
160
161/* Let's try declaring these here. */
162extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
163extern void restore_parser_state __P((sh_parser_state_t *));