]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - shell.h
Bash-4.3 patch 32
[thirdparty/bash.git] / shell.h
diff --git a/shell.h b/shell.h
index 0b1623e58250278e6b011e7daf987dcc940a7c55..3cf25df0bd64155ce45f698d15fd696644c23e5c 100644 (file)
--- a/shell.h
+++ b/shell.h
@@ -1,36 +1,41 @@
 /* shell.h -- The data structures used by the shell */
 
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
-   Bash is free software; you can redistribute it and/or modify it under
-   the terms of the GNU General Public License as published by the Free
-   Software Foundation; either version 2, or (at your option) any later
-   version.
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-   WARRANTY; without even the implied warranty of MERCHANTABILITY or
-   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-   for more details.
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with Bash; see the file COPYING.  If not, write to the Free Software
-   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include "bashjmp.h"
 
 #include "command.h"
+#include "syntax.h"
 #include "general.h"
 #include "error.h"
 #include "variables.h"
+#include "arrayfunc.h"
 #include "quit.h"
 #include "maxpath.h"
 #include "unwind_prot.h"
 #include "dispose_cmd.h"
 #include "make_cmd.h"
+#include "ocache.h"
 #include "subst.h"
 #include "sig.h"
 #include "pathnames.h"
@@ -40,7 +45,6 @@ extern int EOF_Reached;
 
 #define NO_PIPE -1
 #define REDIRECT_BOTH -2
-#define IS_DESCRIPTOR -1
 
 #define NO_VARIABLE -1
 
@@ -51,7 +55,11 @@ extern int EOF_Reached;
 /* Usage messages by builtins result in a return status of 2. */
 #define EX_BADUSAGE    2
 
+#define EX_MISCERROR   2
+
 /* Special exit statuses used by the shell, internally and externally. */
+#define EX_RETRYFAIL   124
+#define EX_WEXPCOMSUB  125
 #define EX_BINARY_FILE 126
 #define EX_NOEXEC      126
 #define EX_NOINPUT     126
@@ -65,47 +73,35 @@ extern int EOF_Reached;
 #define EX_BADASSIGN   260     /* variable assignment error */
 #define EX_EXPFAIL     261     /* word expansion failed */
 
-/* The list of characters that are quoted in double-quotes with a
-   backslash.  Other characters following a backslash cause nothing
-   special to happen. */
-#define slashify_in_quotes "\\`$\"\n"
-#define slashify_in_here_document "\\`$"
-
-/* Constants which specify how to handle backslashes and quoting in
-   expand_word_internal ().  Q_DOUBLE_QUOTES means to use the function
-   slashify_in_quotes () to decide whether the backslash should be
-   retained.  Q_HERE_DOCUMENT means slashify_in_here_document () to
-   decide whether to retain the backslash.  Q_KEEP_BACKSLASH means
-   to unconditionally retain the backslash. */
-#define Q_DOUBLE_QUOTES  0x1
-#define Q_HERE_DOCUMENT  0x2
-#define Q_KEEP_BACKSLASH 0x4
-#define Q_NOQUOTE       0x8
-#define Q_QUOTED        0x10
-#define Q_ADDEDQUOTES   0x20
-#define Q_QUOTEDNULL    0x40
-
 /* Flag values that control parameter pattern substitution. */
-#define MATCH_ANY      0x0
-#define MATCH_BEG      0x1
-#define MATCH_END      0x2
+#define MATCH_ANY      0x000
+#define MATCH_BEG      0x001
+#define MATCH_END      0x002
 
-#define MATCH_TYPEMASK 0x3
+#define MATCH_TYPEMASK 0x003
 
-#define MATCH_GLOBREP  0x10
-#define MATCH_QUOTED   0x20
+#define MATCH_GLOBREP  0x010
+#define MATCH_QUOTED   0x020
+#define MATCH_STARSUB  0x040
 
 /* Some needed external declarations. */
 extern char **shell_environment;
 extern WORD_LIST *rest_of_args;
 
 /* Generalized global variables. */
+extern int debugging_mode;
 extern int executing, login_shell;
+extern int interactive, interactive_shell;
+extern int startup_state;
+extern int subshell_environment;
+extern int shell_compatibility_level;
+
+extern int locale_mb_cur_max;
 
 /* Structure to pass around that holds a bitmap of file descriptors
    to close, and the size of that structure.  Used in execute_cmd.c. */
 struct fd_bitmap {
-  long size;
+  int size;
   char *bitmap;
 };
 
@@ -116,11 +112,78 @@ struct fd_bitmap {
 
 /* Information about the current user. */
 struct user_info {
-  int uid, euid;
-  int gid, egid;
+  uid_t uid, euid;
+  gid_t gid, egid;
   char *user_name;
   char *shell;         /* shell from the password file */
   char *home_dir;
 };
 
 extern struct user_info current_user;
+
+/* Force gcc to not clobber X on a longjmp().  Old versions of gcc mangle
+   this badly. */
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 8)
+#  define USE_VAR(x)   ((void) &(x))
+#else
+#  define USE_VAR(x)
+#endif
+
+/* Structure in which to save partial parsing state when doing things like
+   PROMPT_COMMAND and bash_execute_unix_command execution. */
+
+typedef struct _sh_parser_state_t {
+
+  /* parsing state */
+  int parser_state;
+  int *token_state;
+
+  char *token;
+  int token_buffer_size;
+
+  /* input line state -- line number saved elsewhere */
+  int input_line_terminator;
+  int eof_encountered;
+
+#if defined (HANDLE_MULTIBYTE)
+  /* Nothing right now for multibyte state, but might want something later. */
+#endif
+
+  char **prompt_string_pointer;
+
+  /* history state affecting or modified by the parser */
+  int current_command_line_count;
+#if defined (HISTORY)
+  int remember_on_history;
+  int history_expansion_inhibited;
+#endif
+
+  /* execution state possibly modified by the parser */
+  int last_command_exit_value;
+#if defined (ARRAY_VARS)
+  ARRAY *pipestatus;
+#endif
+  sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
+
+  /* flags state affecting the parser */
+  int expand_aliases;
+  int echo_input_at_read;
+  int need_here_doc;
+
+} sh_parser_state_t;
+
+typedef struct _sh_input_line_state_t {
+  char *input_line;
+  size_t input_line_index;
+  size_t input_line_size;
+  size_t input_line_len;
+} sh_input_line_state_t;
+
+/* Let's try declaring these here. */
+extern char *parser_remaining_input __P((void));
+
+extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
+extern void restore_parser_state __P((sh_parser_state_t *));
+
+extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *));
+extern void restore_input_line_state __P((sh_input_line_state_t *));