/* command.h -- The structures used internally to represent commands, and
the extern declarations of the functions used to create them. */
-/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
r_append_err_and_out
};
+/* Redirection flags; values for rflags */
+#define REDIR_VARASSIGN 0x01
+
/* Redirection errors. */
#define AMBIGUOUS_REDIRECT -1
#define NOCLOBBER_REDIRECT -2
#define RESTRICTED_REDIRECT -3 /* can only happen in restricted shells. */
#define HEREDOC_REDIRECT -4 /* here-doc temp file can't be created */
+#define BADVAR_REDIRECT -5 /* something wrong with {varname}redir */
#define CLOBBERING_REDIRECT(ri) \
(ri == r_output_direction || ri == r_err_and_out)
cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc };
/* Possible values for the `flags' field of a WORD_DESC. */
-#define W_HASDOLLAR 0x000001 /* Dollar sign present. */
-#define W_QUOTED 0x000002 /* Some form of quote character is present. */
-#define W_ASSIGNMENT 0x000004 /* This word is a variable assignment. */
-#define W_GLOBEXP 0x000008 /* This word is the result of a glob expansion. */
-#define W_NOSPLIT 0x000010 /* Do not perform word splitting on this word. */
-#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */
-#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion. */
-#define W_TILDEEXP 0x000080 /* Tilde expand this assignment word */
-#define W_DOLLARAT 0x000100 /* $@ and its special handling */
-#define W_DOLLARSTAR 0x000200 /* $* and its special handling */
-#define W_NOCOMSUB 0x000400 /* Don't perform command substitution on this word */
-#define W_ASSIGNRHS 0x000800 /* Word is rhs of an assignment statement */
-#define W_NOTILDE 0x001000 /* Don't perform tilde expansion on this word */
-#define W_ITILDE 0x002000 /* Internal flag for word expansion */
-#define W_NOEXPAND 0x004000 /* Don't expand at all -- do quote removal */
-#define W_COMPASSIGN 0x008000 /* Compound assignment */
-#define W_ASSNBLTIN 0x010000 /* word is a builtin command that takes assignments */
-#define W_ASSIGNARG 0x020000 /* word is assignment argument to command */
-#define W_HASQUOTEDNULL 0x040000 /* word contains a quoted null character */
-#define W_DQUOTE 0x080000 /* word should be treated as if double-quoted */
-#define W_NOPROCSUB 0x100000 /* don't perform process substitution */
-#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
-#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
+#define W_HASDOLLAR (1 << 0) /* Dollar sign present. */
+#define W_QUOTED (1 << 1) /* Some form of quote character is present. */
+#define W_ASSIGNMENT (1 << 2) /* This word is a variable assignment. */
+#define W_SPLITSPACE (1 << 3) /* Split this word on " " regardless of IFS */
+#define W_NOSPLIT (1 << 4) /* Do not perform word splitting on this word because ifs is empty string. */
+#define W_NOGLOB (1 << 5) /* Do not perform globbing on this word. */
+#define W_NOSPLIT2 (1 << 6) /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */
+#define W_TILDEEXP (1 << 7) /* Tilde expand this assignment word */
+#define W_DOLLARAT (1 << 8) /* UNUSED - $@ and its special handling */
+#define W_ARRAYREF (1 << 9) /* word is a valid array reference */
+#define W_NOCOMSUB (1 << 10) /* Don't perform command substitution on this word */
+#define W_ASSIGNRHS (1 << 11) /* Word is rhs of an assignment statement */
+#define W_NOTILDE (1 << 12) /* Don't perform tilde expansion on this word */
+#define W_NOASSNTILDE (1 << 13) /* don't do tilde expansion like an assignment statement */
+#define W_EXPANDRHS (1 << 14) /* Expanding word in ${paramOPword} */
+#define W_COMPASSIGN (1 << 15) /* Compound assignment */
+#define W_ASSNBLTIN (1 << 16) /* word is a builtin command that takes assignments */
+#define W_ASSIGNARG (1 << 17) /* word is assignment argument to command */
+#define W_HASQUOTEDNULL (1 << 18) /* word contains a quoted null character */
+#define W_DQUOTE (1 << 19) /* UNUSED - word should be treated as if double-quoted */
+#define W_NOPROCSUB (1 << 20) /* don't perform process substitution */
+#define W_SAWQUOTEDNULL (1 << 21) /* word contained a quoted null that was removed */
+#define W_ASSIGNASSOC (1 << 22) /* word looks like associative array assignment */
+#define W_ASSIGNARRAY (1 << 23) /* word looks like a compound indexed array assignment */
+#define W_ARRAYIND (1 << 24) /* word is an array index being expanded */
+#define W_ASSNGLOBAL (1 << 25) /* word is a global assignment to declare (declare/typeset -g) */
+#define W_NOBRACE (1 << 26) /* Don't perform brace expansion */
+#define W_COMPLETE (1 << 27) /* word is being expanded for completion */
+#define W_CHKLOCAL (1 << 28) /* check for local vars on assignment */
+#define W_FORCELOCAL (1 << 29) /* force assignments to be to local variables, non-fatal on assignment errors */
+/* UNUSED (1 << 30) */
+
+/* Flags for the `pflags' argument to param_expand() and various
+ parameter_brace_expand_xxx functions; also used for string_list_dollar_at */
+#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */
+#define PF_IGNUNBOUND 0x02 /* ignore unbound vars even if -u set */
+#define PF_NOSPLIT2 0x04 /* same as W_NOSPLIT2 */
+#define PF_ASSIGNRHS 0x08 /* same as W_ASSIGNRHS */
+#define PF_COMPLETE 0x10 /* same as W_COMPLETE, sets SX_COMPLETE */
+#define PF_EXPANDRHS 0x20 /* same as W_EXPANDRHS */
+#define PF_ALLINDS 0x40 /* array, act as if [@] was supplied */
+#define PF_BACKQUOTE 0x80 /* differentiate `` from $() for command_substitute */
/* Possible values for subshell_environment */
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
#define SUBSHELL_PIPE 0x10 /* subshell from a pipeline element */
#define SUBSHELL_PROCSUB 0x20 /* subshell caused by <(command) or >(command) */
#define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */
+#define SUBSHELL_RESETTRAP 0x80 /* subshell needs to reset trap strings on first call to trap */
+#define SUBSHELL_IGNTRAP 0x100 /* subshell should reset trapped signals from trap_handler */
/* A structure which represents a word. */
typedef struct word_desc {
(or translator in redir.c) encountered an out-of-range file descriptor. */
typedef struct redirect {
struct redirect *next; /* Next element, or NULL. */
- int redirector; /* Descriptor to be redirected. */
+ REDIRECTEE redirector; /* Descriptor or varname to be redirected. */
+ int rflags; /* Private flags for this redirection */
int flags; /* Flag value for `open'. */
enum r_instruction instruction; /* What to do with the information. */
REDIRECTEE redirectee; /* File descriptor or filename */
#define CMD_STDIN_REDIR 0x400 /* async command needs implicit </dev/null */
#define CMD_COMMAND_BUILTIN 0x0800 /* command executed by `command' builtin */
#define CMD_COPROC_SUBSHELL 0x1000
+#define CMD_LASTPIPE 0x2000
+#define CMD_STDPATH 0x4000 /* use standard path for command lookup */
+#define CMD_TRY_OPTIMIZING 0x8000 /* try to optimize this simple command */
/* What a command looks like. */
typedef struct command {
} ARITH_COM;
#endif /* DPAREN_ARITHMETIC */
-/* The conditional command, [[...]]. This is a binary tree -- we slippped
+/* The conditional command, [[...]]. This is a binary tree -- we slipped
a recursive-descent parser into the YACC grammar to parse it. */
#define COND_AND 1
#define COND_OR 2
typedef struct subshell_com {
int flags;
+ int line;
COMMAND *command;
} SUBSHELL_COM;
+#define COPROC_RUNNING 0x01
+#define COPROC_DEAD 0x02
+
typedef struct coproc {
char *c_name;
pid_t c_pid;
int c_wsave;
int c_flags;
int c_status;
+ int c_lock;
} Coproc;
typedef struct coproc_com {
/* Forward declarations of functions declared in copy_cmd.c. */
-extern FUNCTION_DEF *copy_function_def_contents __P((FUNCTION_DEF *, FUNCTION_DEF *));
-extern FUNCTION_DEF *copy_function_def __P((FUNCTION_DEF *));
+extern FUNCTION_DEF *copy_function_def_contents PARAMS((FUNCTION_DEF *, FUNCTION_DEF *));
+extern FUNCTION_DEF *copy_function_def PARAMS((FUNCTION_DEF *));
-extern WORD_DESC *copy_word __P((WORD_DESC *));
-extern WORD_LIST *copy_word_list __P((WORD_LIST *));
-extern REDIRECT *copy_redirect __P((REDIRECT *));
-extern REDIRECT *copy_redirects __P((REDIRECT *));
-extern COMMAND *copy_command __P((COMMAND *));
+extern WORD_DESC *copy_word PARAMS((WORD_DESC *));
+extern WORD_LIST *copy_word_list PARAMS((WORD_LIST *));
+extern REDIRECT *copy_redirect PARAMS((REDIRECT *));
+extern REDIRECT *copy_redirects PARAMS((REDIRECT *));
+extern COMMAND *copy_command PARAMS((COMMAND *));
#endif /* _COMMAND_H_ */