mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-23 13:57:58 +02:00
commit bash-20130118 snapshot
This commit is contained in:
@@ -4343,3 +4343,39 @@ subst.c
|
||||
character is not one for which backslash retains its meaning, add
|
||||
the (escaped) '\' and the (escaped) character. Fixes bug reported
|
||||
by Dan Douglas <ormaaj@gmail.com>
|
||||
|
||||
1/15
|
||||
----
|
||||
builtins/cd.def
|
||||
- cd_builtin: make sure call to internal_getopt handles -e option.
|
||||
Fixes bug reported by <mashimiao.fnst@cn.fujitsu.com>
|
||||
|
||||
1/17
|
||||
----
|
||||
subst.c
|
||||
- expand_word_list_internal: make sure tempenv_assign_error is
|
||||
initialized to 0
|
||||
|
||||
execute_cmd.c
|
||||
- execute_simple_command: make sure tempenv_assign_error is reset to 0
|
||||
after it's tested to see if an error should force the shell to exit.
|
||||
Fixes problem where a the failure of a tempenv assignment preceding
|
||||
a non-special builtin `sticks' and causes the next special builtin
|
||||
to exit the shell. From a discussion on bug-bash started by
|
||||
douxin <wq-doux@cn.fujitsu.com>
|
||||
|
||||
1/20
|
||||
----
|
||||
subst.c
|
||||
- parameter_brace_expand_rhs: call stupidly_hack_special_variables
|
||||
after assigning with ${param[:]=word} even if IFS is changing.
|
||||
Suggested by Dan Douglas <ormaaj@gmail.com> [TENTATIVE, needs work
|
||||
on IFS side effects]
|
||||
|
||||
command.h
|
||||
- W_GLOBEXP (which was unused) is now W_SPLITSPACE (which isn't used
|
||||
yet)
|
||||
|
||||
{execute_cmd,subst,variables}.c
|
||||
- removed all code that mentioned W_GLOBEXP
|
||||
- removed mention of gnu_argv_flags and code that set it
|
||||
|
||||
@@ -4336,3 +4336,45 @@ redir.c
|
||||
expandable_redirection_filename returns true), disable command
|
||||
substitution during expansion. Fixes bug reported by Dan Douglas
|
||||
<ormaaj@gmail.com>
|
||||
|
||||
subst.c
|
||||
- expand_word_internal: case '\\': if the next character is an IFS
|
||||
character, and the expansion occurs within double quotes, and the
|
||||
character is not one for which backslash retains its meaning, add
|
||||
the (escaped) '\' and the (escaped) character. Fixes bug reported
|
||||
by Dan Douglas <ormaaj@gmail.com>
|
||||
|
||||
1/15
|
||||
----
|
||||
builtins/cd.def
|
||||
- cd_builtin: make sure call to internal_getopt handles -e option.
|
||||
Fixes bug reported by <mashimiao.fnst@cn.fujitsu.com>
|
||||
|
||||
1/17
|
||||
----
|
||||
subst.c
|
||||
- expand_word_list_internal: make sure tempenv_assign_error is
|
||||
initialized to 0
|
||||
|
||||
execute_cmd.c
|
||||
- execute_simple_command: make sure tempenv_assign_error is reset to 0
|
||||
after it's tested to see if an error should force the shell to exit.
|
||||
Fixes problem where a the failure of a tempenv assignment preceding
|
||||
a non-special builtin `sticks' and causes the next special builtin
|
||||
to exit the shell. From a discussion on bug-bash started by
|
||||
douxin <wq-doux@cn.fujitsu.com>
|
||||
|
||||
1/20
|
||||
----
|
||||
subst.c
|
||||
- parameter_brace_expand_rhs: call stupidly_hack_special_variables
|
||||
after assigning with ${param[:]=word} even if IFS is changing.
|
||||
Suggested by Dan Douglas <ormaaj@gmail.com> [TENTATIVE, needs work
|
||||
on IFS side effects]
|
||||
|
||||
command.h,subst.c
|
||||
- W_GLOBEXP (which was unused) is now W_SPLITSPACE (which isn't used
|
||||
yet), removed all code that mentioned W_GLOBEXP
|
||||
|
||||
{execute_cmd,subst,variables}.c
|
||||
- removed mention of gnu_argv_flags
|
||||
|
||||
@@ -634,11 +634,11 @@ examples/loadables/realpath.c f
|
||||
examples/loadables/sleep.c f
|
||||
examples/loadables/strftime.c f
|
||||
examples/loadables/truefalse.c f
|
||||
examples/loadables/getconf.h f
|
||||
examples/loadables/getconf.c f
|
||||
#examples/loadables/getconf.h f
|
||||
#examples/loadables/getconf.c f
|
||||
examples/loadables/finfo.c f
|
||||
examples/loadables/cat.c f
|
||||
examples/loadables/cut.c f
|
||||
#examples/loadables/cut.c f
|
||||
examples/loadables/logname.c f
|
||||
examples/loadables/basename.c f
|
||||
examples/loadables/dirname.c f
|
||||
@@ -699,8 +699,8 @@ examples/functions/manpage f
|
||||
examples/functions/mhfold f
|
||||
examples/functions/newdirstack.bsh f
|
||||
examples/functions/notify.bash f
|
||||
examples/functions/pathfuncs f
|
||||
examples/functions/recurse f
|
||||
#examples/functions/pathfuncs f
|
||||
#examples/functions/recurse f
|
||||
examples/functions/repeat2 f
|
||||
examples/functions/repeat3 f
|
||||
examples/functions/seq f
|
||||
@@ -742,7 +742,7 @@ examples/scripts/timeout3 f
|
||||
examples/scripts/vtree2 f
|
||||
examples/scripts/vtree3 f
|
||||
examples/scripts/vtree3a f
|
||||
examples/scripts/websrv.sh f
|
||||
#examples/scripts/websrv.sh f
|
||||
examples/scripts/xterm_title f
|
||||
examples/scripts/zprintf f
|
||||
examples/startup-files/README f
|
||||
|
||||
+1
-1
@@ -204,7 +204,7 @@ cd_builtin (list)
|
||||
eflag = 0;
|
||||
no_symlinks = no_symbolic_links;
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "LP")) != -1)
|
||||
while ((opt = internal_getopt (list, "eLP")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
#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_SPLITSPACE 0x000008 /* Split this word on " " regardless of IFS */
|
||||
#define W_NOSPLIT 0x000010 /* Do not perform word splitting on this word because ifs is empty string. */
|
||||
#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */
|
||||
|
||||
+391
@@ -0,0 +1,391 @@
|
||||
/* command.h -- The structures used internally to represent commands, and
|
||||
the extern declarations of the functions used to create them. */
|
||||
|
||||
/* Copyright (C) 1993-2010 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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_COMMAND_H_)
|
||||
#define _COMMAND_H_
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
/* Instructions describing what kind of thing to do for a redirection. */
|
||||
enum r_instruction {
|
||||
r_output_direction, r_input_direction, r_inputa_direction,
|
||||
r_appending_to, r_reading_until, r_reading_string,
|
||||
r_duplicating_input, r_duplicating_output, r_deblank_reading_until,
|
||||
r_close_this, r_err_and_out, r_input_output, r_output_force,
|
||||
r_duplicating_input_word, r_duplicating_output_word,
|
||||
r_move_input, r_move_output, r_move_input_word, r_move_output_word,
|
||||
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)
|
||||
|
||||
#define OUTPUT_REDIRECT(ri) \
|
||||
(ri == r_output_direction || ri == r_input_output || ri == r_err_and_out || ri == r_append_err_and_out)
|
||||
|
||||
#define INPUT_REDIRECT(ri) \
|
||||
(ri == r_input_direction || ri == r_inputa_direction || ri == r_input_output)
|
||||
|
||||
#define WRITE_REDIRECT(ri) \
|
||||
(ri == r_output_direction || \
|
||||
ri == r_input_output || \
|
||||
ri == r_err_and_out || \
|
||||
ri == r_appending_to || \
|
||||
ri == r_append_err_and_out || \
|
||||
ri == r_output_force)
|
||||
|
||||
/* redirection needs translation */
|
||||
#define TRANSLATE_REDIRECT(ri) \
|
||||
(ri == r_duplicating_input_word || ri == r_duplicating_output_word || \
|
||||
ri == r_move_input_word || ri == r_move_output_word)
|
||||
|
||||
/* Command Types: */
|
||||
enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
||||
cm_connection, cm_function_def, cm_until, cm_group,
|
||||
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 because ifs is empty string. */
|
||||
#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */
|
||||
#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */
|
||||
#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_ASSIGNARRAY 0x800000 /* word looks like a compound indexed array assignment */
|
||||
#define W_ARRAYIND 0x1000000 /* word is an array index being expanded */
|
||||
#define W_ASSNGLOBAL 0x2000000 /* word is a global assignment to declare (declare/typeset -g) */
|
||||
#define W_NOBRACE 0x4000000 /* Don't perform brace expansion */
|
||||
|
||||
/* Possible values for subshell_environment */
|
||||
#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */
|
||||
#define SUBSHELL_PAREN 0x02 /* subshell caused by ( ... ) */
|
||||
#define SUBSHELL_COMSUB 0x04 /* subshell caused by `command` or $(command) */
|
||||
#define SUBSHELL_FORK 0x08 /* subshell caused by executing a disk 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 */
|
||||
|
||||
/* A structure which represents a word. */
|
||||
typedef struct word_desc {
|
||||
char *word; /* Zero terminated string. */
|
||||
int flags; /* Flags associated with this word. */
|
||||
} WORD_DESC;
|
||||
|
||||
/* A linked list of words. */
|
||||
typedef struct word_list {
|
||||
struct word_list *next;
|
||||
WORD_DESC *word;
|
||||
} WORD_LIST;
|
||||
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Shell Command Structs */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* What a redirection descriptor looks like. If the redirection instruction
|
||||
is ri_duplicating_input or ri_duplicating_output, use DEST, otherwise
|
||||
use the file in FILENAME. Out-of-range descriptors are identified by a
|
||||
negative DEST. */
|
||||
|
||||
typedef union {
|
||||
int dest; /* Place to redirect REDIRECTOR to, or ... */
|
||||
WORD_DESC *filename; /* filename to redirect to. */
|
||||
} REDIRECTEE;
|
||||
|
||||
/* Structure describing a redirection. If REDIRECTOR is negative, the parser
|
||||
(or translator in redir.c) encountered an out-of-range file descriptor. */
|
||||
typedef struct redirect {
|
||||
struct redirect *next; /* Next element, or NULL. */
|
||||
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 */
|
||||
char *here_doc_eof; /* The word that appeared in <<foo. */
|
||||
} REDIRECT;
|
||||
|
||||
/* An element used in parsing. A single word or a single redirection.
|
||||
This is an ephemeral construct. */
|
||||
typedef struct element {
|
||||
WORD_DESC *word;
|
||||
REDIRECT *redirect;
|
||||
} ELEMENT;
|
||||
|
||||
/* Possible values for command->flags. */
|
||||
#define CMD_WANT_SUBSHELL 0x01 /* User wants a subshell: ( command ) */
|
||||
#define CMD_FORCE_SUBSHELL 0x02 /* Shell needs to force a subshell. */
|
||||
#define CMD_INVERT_RETURN 0x04 /* Invert the exit value. */
|
||||
#define CMD_IGNORE_RETURN 0x08 /* Ignore the exit value. For set -e. */
|
||||
#define CMD_NO_FUNCTIONS 0x10 /* Ignore functions during command lookup. */
|
||||
#define CMD_INHIBIT_EXPANSION 0x20 /* Do not expand the command words. */
|
||||
#define CMD_NO_FORK 0x40 /* Don't fork; just call execve */
|
||||
#define CMD_TIME_PIPELINE 0x80 /* Time a pipeline */
|
||||
#define CMD_TIME_POSIX 0x100 /* time -p; use POSIX.2 time output spec. */
|
||||
#define CMD_AMPERSAND 0x200 /* command & */
|
||||
#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
|
||||
|
||||
/* What a command looks like. */
|
||||
typedef struct command {
|
||||
enum command_type type; /* FOR CASE WHILE IF CONNECTION or SIMPLE. */
|
||||
int flags; /* Flags controlling execution environment. */
|
||||
int line; /* line number the command starts on */
|
||||
REDIRECT *redirects; /* Special redirects for FOR CASE, etc. */
|
||||
union {
|
||||
struct for_com *For;
|
||||
struct case_com *Case;
|
||||
struct while_com *While;
|
||||
struct if_com *If;
|
||||
struct connection *Connection;
|
||||
struct simple_com *Simple;
|
||||
struct function_def *Function_def;
|
||||
struct group_com *Group;
|
||||
#if defined (SELECT_COMMAND)
|
||||
struct select_com *Select;
|
||||
#endif
|
||||
#if defined (DPAREN_ARITHMETIC)
|
||||
struct arith_com *Arith;
|
||||
#endif
|
||||
#if defined (COND_COMMAND)
|
||||
struct cond_com *Cond;
|
||||
#endif
|
||||
#if defined (ARITH_FOR_COMMAND)
|
||||
struct arith_for_com *ArithFor;
|
||||
#endif
|
||||
struct subshell_com *Subshell;
|
||||
struct coproc_com *Coproc;
|
||||
} value;
|
||||
} COMMAND;
|
||||
|
||||
/* Structure used to represent the CONNECTION type. */
|
||||
typedef struct connection {
|
||||
int ignore; /* Unused; simplifies make_command (). */
|
||||
COMMAND *first; /* Pointer to the first command. */
|
||||
COMMAND *second; /* Pointer to the second command. */
|
||||
int connector; /* What separates this command from others. */
|
||||
} CONNECTION;
|
||||
|
||||
/* Structures used to represent the CASE command. */
|
||||
|
||||
/* Values for FLAGS word in a PATTERN_LIST */
|
||||
#define CASEPAT_FALLTHROUGH 0x01
|
||||
#define CASEPAT_TESTNEXT 0x02
|
||||
|
||||
/* Pattern/action structure for CASE_COM. */
|
||||
typedef struct pattern_list {
|
||||
struct pattern_list *next; /* Clause to try in case this one failed. */
|
||||
WORD_LIST *patterns; /* Linked list of patterns to test. */
|
||||
COMMAND *action; /* Thing to execute if a pattern matches. */
|
||||
int flags;
|
||||
} PATTERN_LIST;
|
||||
|
||||
/* The CASE command. */
|
||||
typedef struct case_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `case' keyword appears on */
|
||||
WORD_DESC *word; /* The thing to test. */
|
||||
PATTERN_LIST *clauses; /* The clauses to test against, or NULL. */
|
||||
} CASE_COM;
|
||||
|
||||
/* FOR command. */
|
||||
typedef struct for_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `for' keyword appears on */
|
||||
WORD_DESC *name; /* The variable name to get mapped over. */
|
||||
WORD_LIST *map_list; /* The things to map over. This is never NULL. */
|
||||
COMMAND *action; /* The action to execute.
|
||||
During execution, NAME is bound to successive
|
||||
members of MAP_LIST. */
|
||||
} FOR_COM;
|
||||
|
||||
#if defined (ARITH_FOR_COMMAND)
|
||||
typedef struct arith_for_com {
|
||||
int flags;
|
||||
int line; /* generally used for error messages */
|
||||
WORD_LIST *init;
|
||||
WORD_LIST *test;
|
||||
WORD_LIST *step;
|
||||
COMMAND *action;
|
||||
} ARITH_FOR_COM;
|
||||
#endif
|
||||
|
||||
#if defined (SELECT_COMMAND)
|
||||
/* KSH SELECT command. */
|
||||
typedef struct select_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the `select' keyword appears on */
|
||||
WORD_DESC *name; /* The variable name to get mapped over. */
|
||||
WORD_LIST *map_list; /* The things to map over. This is never NULL. */
|
||||
COMMAND *action; /* The action to execute.
|
||||
During execution, NAME is bound to the member of
|
||||
MAP_LIST chosen by the user. */
|
||||
} SELECT_COM;
|
||||
#endif /* SELECT_COMMAND */
|
||||
|
||||
/* IF command. */
|
||||
typedef struct if_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
COMMAND *test; /* Thing to test. */
|
||||
COMMAND *true_case; /* What to do if the test returned non-zero. */
|
||||
COMMAND *false_case; /* What to do if the test returned zero. */
|
||||
} IF_COM;
|
||||
|
||||
/* WHILE command. */
|
||||
typedef struct while_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
COMMAND *test; /* Thing to test. */
|
||||
COMMAND *action; /* Thing to do while test is non-zero. */
|
||||
} WHILE_COM;
|
||||
|
||||
#if defined (DPAREN_ARITHMETIC)
|
||||
/* The arithmetic evaluation command, ((...)). Just a set of flags and
|
||||
a WORD_LIST, of which the first element is the only one used, for the
|
||||
time being. */
|
||||
typedef struct arith_com {
|
||||
int flags;
|
||||
int line;
|
||||
WORD_LIST *exp;
|
||||
} ARITH_COM;
|
||||
#endif /* DPAREN_ARITHMETIC */
|
||||
|
||||
/* The conditional command, [[...]]. This is a binary tree -- we slippped
|
||||
a recursive-descent parser into the YACC grammar to parse it. */
|
||||
#define COND_AND 1
|
||||
#define COND_OR 2
|
||||
#define COND_UNARY 3
|
||||
#define COND_BINARY 4
|
||||
#define COND_TERM 5
|
||||
#define COND_EXPR 6
|
||||
|
||||
typedef struct cond_com {
|
||||
int flags;
|
||||
int line;
|
||||
int type;
|
||||
WORD_DESC *op;
|
||||
struct cond_com *left, *right;
|
||||
} COND_COM;
|
||||
|
||||
/* The "simple" command. Just a collection of words and redirects. */
|
||||
typedef struct simple_com {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* line number the command starts on */
|
||||
WORD_LIST *words; /* The program name, the arguments,
|
||||
variable assignments, etc. */
|
||||
REDIRECT *redirects; /* Redirections to perform. */
|
||||
} SIMPLE_COM;
|
||||
|
||||
/* The "function definition" command. */
|
||||
typedef struct function_def {
|
||||
int flags; /* See description of CMD flags. */
|
||||
int line; /* Line number the function def starts on. */
|
||||
WORD_DESC *name; /* The name of the function. */
|
||||
COMMAND *command; /* The parsed execution tree. */
|
||||
char *source_file; /* file in which function was defined, if any */
|
||||
} FUNCTION_DEF;
|
||||
|
||||
/* A command that is `grouped' allows pipes and redirections to affect all
|
||||
commands in the group. */
|
||||
typedef struct group_com {
|
||||
int ignore; /* See description of CMD flags. */
|
||||
COMMAND *command;
|
||||
} GROUP_COM;
|
||||
|
||||
typedef struct subshell_com {
|
||||
int flags;
|
||||
COMMAND *command;
|
||||
} SUBSHELL_COM;
|
||||
|
||||
#define COPROC_RUNNING 0x01
|
||||
#define COPROC_DEAD 0x02
|
||||
|
||||
typedef struct coproc {
|
||||
char *c_name;
|
||||
pid_t c_pid;
|
||||
int c_rfd;
|
||||
int c_wfd;
|
||||
int c_rsave;
|
||||
int c_wsave;
|
||||
int c_flags;
|
||||
int c_status;
|
||||
int c_lock;
|
||||
} Coproc;
|
||||
|
||||
typedef struct coproc_com {
|
||||
int flags;
|
||||
char *name;
|
||||
COMMAND *command;
|
||||
} COPROC_COM;
|
||||
|
||||
extern COMMAND *global_command;
|
||||
extern Coproc sh_coproc;
|
||||
|
||||
/* Possible command errors */
|
||||
#define CMDERR_DEFAULT 0
|
||||
#define CMDERR_BADTYPE 1
|
||||
#define CMDERR_BADCONN 2
|
||||
#define CMDERR_BADJUMP 3
|
||||
|
||||
#define CMDERR_LAST 3
|
||||
|
||||
/* 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 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 *));
|
||||
|
||||
#endif /* _COMMAND_H_ */
|
||||
+1
-8
@@ -4018,6 +4018,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
|
||||
last_command_exit_value = EXECUTION_FAILURE;
|
||||
jump_to_top_level (ERREXIT);
|
||||
}
|
||||
tempenv_assign_error = 0; /* don't care about this any more */
|
||||
|
||||
add_unwind_protect (dispose_words, words);
|
||||
QUIT;
|
||||
@@ -4866,14 +4867,6 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
|
||||
{
|
||||
int old_interactive;
|
||||
|
||||
#if 0
|
||||
/* This has been disabled for the time being. */
|
||||
#if !defined (ARG_MAX) || ARG_MAX >= 10240
|
||||
if (posixly_correct == 0)
|
||||
put_gnu_argv_flags_into_env ((long)getpid (), glob_argv_flags);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
reset_terminating_signals (); /* XXX */
|
||||
/* Cancel traps, in trap.c. */
|
||||
restore_original_signals ();
|
||||
|
||||
+1
-1
@@ -4018,6 +4018,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
|
||||
last_command_exit_value = EXECUTION_FAILURE;
|
||||
jump_to_top_level (ERREXIT);
|
||||
}
|
||||
tempenv_assign_error = 0; /* don't care about this any more */
|
||||
|
||||
add_unwind_protect (dispose_words, words);
|
||||
QUIT;
|
||||
@@ -4876,7 +4877,6 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
|
||||
|
||||
reset_terminating_signals (); /* XXX */
|
||||
/* Cancel traps, in trap.c. */
|
||||
itrace("execute_disk_command: calling restore_original_signals");
|
||||
restore_original_signals ();
|
||||
|
||||
/* restore_original_signals may have undone the work done
|
||||
|
||||
@@ -135,6 +135,7 @@ pid_t current_command_subst_pid = NO_PID;
|
||||
SHELL_VAR *ifs_var;
|
||||
char *ifs_value;
|
||||
unsigned char ifs_cmap[UCHAR_MAX + 1];
|
||||
int ifs_is_set, ifs_is_null;
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
unsigned char ifs_firstc[MB_LEN_MAX];
|
||||
@@ -443,10 +444,10 @@ dump_word_flags (flags)
|
||||
f &= ~W_NOGLOB;
|
||||
fprintf (stderr, "W_NOGLOB%s", f ? "|" : "");
|
||||
}
|
||||
if (f & W_GLOBEXP)
|
||||
if (f & W_SPLITSPACE)
|
||||
{
|
||||
f &= ~W_GLOBEXP;
|
||||
fprintf (stderr, "W_GLOBEXP%s", f ? "|" : "");
|
||||
f &= ~W_SPLITSPACE;
|
||||
fprintf (stderr, "W_SPLITSPACE%s", f ? "|" : "");
|
||||
}
|
||||
if (f & W_ASSIGNMENT)
|
||||
{
|
||||
@@ -1457,18 +1458,6 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Pass the contents of single-quoted and double-quoted strings
|
||||
through verbatim. */
|
||||
if (c == '\'' || c == '"')
|
||||
{
|
||||
si = i + 1;
|
||||
i = (c == '\'') ? skip_single_quoted (string, slen, si)
|
||||
: skip_double_quoted (string, slen, si);
|
||||
/* skip_XXX_quoted leaves index one past close quote */
|
||||
continue;
|
||||
}
|
||||
#else /* XXX - bash-4.2 */
|
||||
/* Pass the contents of double-quoted strings through verbatim. */
|
||||
if (c == '"')
|
||||
{
|
||||
@@ -1491,7 +1480,6 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* move past this character, which was not special. */
|
||||
ADVANCE_CHAR (string, slen, i);
|
||||
@@ -4082,9 +4070,6 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
{
|
||||
if (match_pattern_char (pat, p))
|
||||
{
|
||||
#if 0
|
||||
for (p1 = end; p1 >= p; p1--)
|
||||
#else
|
||||
p1 = (mlen == -1) ? end : p + mlen;
|
||||
/* p1 - p = length of portion of string to be considered
|
||||
p = current position in string
|
||||
@@ -4097,7 +4082,6 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
if (p1 > end)
|
||||
break;
|
||||
for ( ; p1 >= p; p1--)
|
||||
#endif
|
||||
{
|
||||
c = *p1; *p1 = '\0';
|
||||
if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4123,11 +4107,7 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
if (match_pattern_char (pat, string) == 0)
|
||||
return (0);
|
||||
|
||||
#if 0
|
||||
for (p = end; p >= string; p--)
|
||||
#else
|
||||
for (p = (mlen == -1) ? end : string + mlen; p >= string; p--)
|
||||
#endif
|
||||
{
|
||||
c = *p; *p = '\0';
|
||||
if (strmatch (pat, string, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4138,21 +4118,15 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
*p = c;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
case MATCH_END:
|
||||
#if 0
|
||||
for (p = string; p <= end; p++)
|
||||
#else
|
||||
for (p = end - ((mlen == -1) ? len : mlen); p <= end; p++)
|
||||
#endif
|
||||
{
|
||||
if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0)
|
||||
{
|
||||
@@ -4160,11 +4134,9 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
*ep = end;
|
||||
return 1;
|
||||
}
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -4232,22 +4204,14 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
case MATCH_ANY:
|
||||
for (n = 0; n <= wstrlen; n++)
|
||||
{
|
||||
#if 1
|
||||
n2 = simple ? (*wpat == wstring[n]) : match_pattern_wchar (wpat, wstring + n);
|
||||
#else
|
||||
n2 = match_pattern_wchar (wpat, wstring + n);
|
||||
#endif
|
||||
if (n2)
|
||||
{
|
||||
#if 0
|
||||
for (n1 = wstrlen; n1 >= n; n1--)
|
||||
#else
|
||||
n1 = (mlen == -1) ? wstrlen : n + mlen;
|
||||
if (n1 > wstrlen)
|
||||
break;
|
||||
|
||||
for ( ; n1 >= n; n1--)
|
||||
#endif
|
||||
{
|
||||
wc = wstring[n1]; wstring[n1] = L'\0';
|
||||
if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4258,11 +4222,9 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
wstring[n1] = wc;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4273,11 +4235,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
if (match_pattern_wchar (wpat, wstring) == 0)
|
||||
return (0);
|
||||
|
||||
#if 0
|
||||
for (n = wstrlen; n >= 0; n--)
|
||||
#else
|
||||
for (n = (mlen == -1) ? wstrlen : mlen; n >= 0; n--)
|
||||
#endif
|
||||
{
|
||||
wc = wstring[n]; wstring[n] = L'\0';
|
||||
if (wcsmatch (wpat, wstring, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4288,21 +4246,15 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
wstring[n] = wc;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
case MATCH_END:
|
||||
#if 0
|
||||
for (n = 0; n <= wstrlen; n++)
|
||||
#else
|
||||
for (n = wstrlen - ((mlen == -1) ? wstrlen : mlen); n <= wstrlen; n++)
|
||||
#endif
|
||||
{
|
||||
if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0)
|
||||
{
|
||||
@@ -4310,11 +4262,9 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
*ep = indices[wstrlen];
|
||||
return 1;
|
||||
}
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -4344,15 +4294,7 @@ match_pattern (string, pat, mtype, sp, ep)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
#if 0
|
||||
slen = STRLEN (string);
|
||||
mslen = MBSLEN (string);
|
||||
plen = STRLEN (pat);
|
||||
mplen = MBSLEN (pat);
|
||||
if (slen == mslen && plen == mplen)
|
||||
#else
|
||||
if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0)
|
||||
#endif
|
||||
return (match_upattern (string, pat, mtype, sp, ep));
|
||||
|
||||
n = xdupmbstowcs (&wpat, NULL, pat);
|
||||
@@ -5935,11 +5877,10 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
|
||||
else
|
||||
#endif /* ARRAY_VARS */
|
||||
bind_variable (name, t1, 0);
|
||||
#if 0
|
||||
if (STREQ (name, "IFS") == 0)
|
||||
#endif
|
||||
stupidly_hack_special_variables (name);
|
||||
else
|
||||
/* XXX - what to do? Set a flag in w->flags to call setifs() later? */
|
||||
;
|
||||
|
||||
/* From Posix group discussion Feb-March 2010. Issue 7 0000221 */
|
||||
free (temp);
|
||||
@@ -6661,18 +6602,7 @@ pos_params_pat_subst (string, pat, rep, mflags)
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
#if 0
|
||||
if ((mflags & (MATCH_QUOTED|MATCH_STARSUB)) == (MATCH_QUOTED|MATCH_STARSUB))
|
||||
ret = string_list_dollar_star (quote_list (save));
|
||||
else if ((mflags & MATCH_STARSUB) == MATCH_STARSUB)
|
||||
ret = string_list_dollar_star (save);
|
||||
else if ((mflags & MATCH_QUOTED) == MATCH_QUOTED)
|
||||
ret = string_list_dollar_at (save, qflags);
|
||||
else
|
||||
ret = string_list_dollar_star (save);
|
||||
#else
|
||||
ret = string_list_pos_params (pchar, save, qflags);
|
||||
#endif
|
||||
|
||||
dispose_words (save);
|
||||
|
||||
@@ -7691,7 +7621,6 @@ param_expand (string, sindex, quoted, expanded_something,
|
||||
an assignment statement. In that case, we don't separate the
|
||||
arguments at all. Otherwise, if the $* is not quoted it is
|
||||
identical to $@ */
|
||||
#if 1
|
||||
# if defined (HANDLE_MULTIBYTE)
|
||||
if (expand_no_split_dollar_star && ifs_firstc[0] == 0)
|
||||
# else
|
||||
@@ -7699,10 +7628,15 @@ param_expand (string, sindex, quoted, expanded_something,
|
||||
# endif
|
||||
temp = string_list_dollar_star (list);
|
||||
else
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
#else
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
#endif
|
||||
{
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
if (ifs_is_set == 0 || ifs_is_null)
|
||||
{
|
||||
itrace("param_expand: set W_SPLITSPACE flag");
|
||||
tflag |= W_SPLITSPACE;
|
||||
}
|
||||
}
|
||||
|
||||
if (expand_no_split_dollar_star == 0 && contains_dollar_at)
|
||||
*contains_dollar_at = 1;
|
||||
}
|
||||
@@ -8064,6 +7998,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
|
||||
/* State flags */
|
||||
int had_quoted_null;
|
||||
int has_dollar_at, temp_has_dollar_at;
|
||||
int split_on_spaces;
|
||||
int tflag;
|
||||
int pflags; /* flags passed to param_expand */
|
||||
|
||||
@@ -8079,6 +8014,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
|
||||
istring = (char *)xmalloc (istring_size = DEFAULT_INITIAL_ARRAY_SIZE);
|
||||
istring[istring_index = 0] = '\0';
|
||||
quoted_dollar_at = had_quoted_null = has_dollar_at = 0;
|
||||
split_on_spaces = 0;
|
||||
quoted_state = UNQUOTED;
|
||||
|
||||
string = word->word;
|
||||
@@ -8279,6 +8215,10 @@ add_string:
|
||||
&had_quoted_null, pflags);
|
||||
has_dollar_at += temp_has_dollar_at;
|
||||
|
||||
split_on_spaces += (tword->flags & W_SPLITSPACE);
|
||||
if (tword->flags & W_SPLITSPACE)
|
||||
itrace("expand_word_internal: param_expand return word has W_SPLITSPACE");
|
||||
|
||||
if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal)
|
||||
{
|
||||
free (string);
|
||||
@@ -8407,11 +8347,7 @@ add_twochars:
|
||||
break;
|
||||
|
||||
case '"':
|
||||
#if 0
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE))
|
||||
#else
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
|
||||
#endif
|
||||
goto add_character;
|
||||
|
||||
t_index = ++sindex;
|
||||
@@ -8499,11 +8435,6 @@ add_twochars:
|
||||
{
|
||||
if (list->next)
|
||||
{
|
||||
#if 0
|
||||
if (quoted_dollar_at && (word->flags & W_NOSPLIT2))
|
||||
temp = string_list_internal (quote_list (list), " ");
|
||||
else
|
||||
#endif
|
||||
/* Testing quoted_dollar_at makes sure that "$@" is
|
||||
split correctly when $IFS does not contain a space. */
|
||||
temp = quoted_dollar_at
|
||||
@@ -8566,11 +8497,7 @@ add_twochars:
|
||||
/* break; */
|
||||
|
||||
case '\'':
|
||||
#if 0
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE))
|
||||
#else
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
|
||||
#endif
|
||||
goto add_character;
|
||||
|
||||
t_index = ++sindex;
|
||||
@@ -8733,6 +8660,7 @@ finished_with_string:
|
||||
{
|
||||
char *ifs_chars;
|
||||
|
||||
itrace("expand_word_internal: splitting `%s': split_on_spaces = %d", istring, split_on_spaces);
|
||||
ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
|
||||
|
||||
/* If we have $@, we need to split the results no matter what. If
|
||||
@@ -8904,6 +8832,9 @@ setifs (v)
|
||||
ifs_var = v;
|
||||
ifs_value = (v && value_cell (v)) ? value_cell (v) : " \t\n";
|
||||
|
||||
ifs_is_set = ifs_var != 0;
|
||||
ifs_is_null = ifs_is_set && (*ifs_value == 0);
|
||||
|
||||
/* Should really merge ifs_cmap with sh_syntaxtab. XXX - doesn't yet
|
||||
handle multibyte chars in IFS */
|
||||
memset (ifs_cmap, '\0', sizeof (ifs_cmap));
|
||||
@@ -9216,7 +9147,6 @@ glob_expand_word_list (tlist, eflags)
|
||||
for (glob_index = 0; glob_array[glob_index]; glob_index++)
|
||||
{
|
||||
tword = make_bare_word (glob_array[glob_index]);
|
||||
tword->flags |= W_GLOBEXP; /* XXX */
|
||||
glob_list = make_word_list (tword, glob_list);
|
||||
}
|
||||
|
||||
@@ -9491,6 +9421,7 @@ expand_word_list_internal (list, eflags)
|
||||
WORD_LIST *new_list, *temp_list;
|
||||
int tint;
|
||||
|
||||
tempenv_assign_error = 0;
|
||||
if (list == 0)
|
||||
return ((WORD_LIST *)NULL);
|
||||
|
||||
@@ -9596,13 +9527,5 @@ expand_word_list_internal (list, eflags)
|
||||
subst_assign_varlist = (WORD_LIST *)NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
tint = list_length (new_list) + 1;
|
||||
RESIZE_MALLOCED_BUFFER (glob_argv_flags, 0, tint, glob_argv_flags_size, 16);
|
||||
for (tint = 0, temp_list = new_list; temp_list; temp_list = temp_list->next)
|
||||
glob_argv_flags[tint++] = (temp_list->word->flags & W_GLOBEXP) ? '1' : '0';
|
||||
glob_argv_flags[tint] = '\0';
|
||||
#endif
|
||||
|
||||
return (new_list);
|
||||
}
|
||||
|
||||
+9546
File diff suppressed because it is too large
Load Diff
@@ -135,6 +135,7 @@ pid_t current_command_subst_pid = NO_PID;
|
||||
SHELL_VAR *ifs_var;
|
||||
char *ifs_value;
|
||||
unsigned char ifs_cmap[UCHAR_MAX + 1];
|
||||
int ifs_is_set, ifs_is_null;
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
unsigned char ifs_firstc[MB_LEN_MAX];
|
||||
@@ -443,10 +444,10 @@ dump_word_flags (flags)
|
||||
f &= ~W_NOGLOB;
|
||||
fprintf (stderr, "W_NOGLOB%s", f ? "|" : "");
|
||||
}
|
||||
if (f & W_GLOBEXP)
|
||||
if (f & W_SPLITSPACE)
|
||||
{
|
||||
f &= ~W_GLOBEXP;
|
||||
fprintf (stderr, "W_GLOBEXP%s", f ? "|" : "");
|
||||
f &= ~W_SPLITSPACE;
|
||||
fprintf (stderr, "W_SPLITSPACE%s", f ? "|" : "");
|
||||
}
|
||||
if (f & W_ASSIGNMENT)
|
||||
{
|
||||
@@ -1457,18 +1458,6 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Pass the contents of single-quoted and double-quoted strings
|
||||
through verbatim. */
|
||||
if (c == '\'' || c == '"')
|
||||
{
|
||||
si = i + 1;
|
||||
i = (c == '\'') ? skip_single_quoted (string, slen, si)
|
||||
: skip_double_quoted (string, slen, si);
|
||||
/* skip_XXX_quoted leaves index one past close quote */
|
||||
continue;
|
||||
}
|
||||
#else /* XXX - bash-4.2 */
|
||||
/* Pass the contents of double-quoted strings through verbatim. */
|
||||
if (c == '"')
|
||||
{
|
||||
@@ -1491,7 +1480,6 @@ extract_dollar_brace_string (string, sindex, quoted, flags)
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* move past this character, which was not special. */
|
||||
ADVANCE_CHAR (string, slen, i);
|
||||
@@ -4082,9 +4070,6 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
{
|
||||
if (match_pattern_char (pat, p))
|
||||
{
|
||||
#if 0
|
||||
for (p1 = end; p1 >= p; p1--)
|
||||
#else
|
||||
p1 = (mlen == -1) ? end : p + mlen;
|
||||
/* p1 - p = length of portion of string to be considered
|
||||
p = current position in string
|
||||
@@ -4097,7 +4082,6 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
if (p1 > end)
|
||||
break;
|
||||
for ( ; p1 >= p; p1--)
|
||||
#endif
|
||||
{
|
||||
c = *p1; *p1 = '\0';
|
||||
if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4123,11 +4107,7 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
if (match_pattern_char (pat, string) == 0)
|
||||
return (0);
|
||||
|
||||
#if 0
|
||||
for (p = end; p >= string; p--)
|
||||
#else
|
||||
for (p = (mlen == -1) ? end : string + mlen; p >= string; p--)
|
||||
#endif
|
||||
{
|
||||
c = *p; *p = '\0';
|
||||
if (strmatch (pat, string, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4138,21 +4118,15 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
*p = c;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
case MATCH_END:
|
||||
#if 0
|
||||
for (p = string; p <= end; p++)
|
||||
#else
|
||||
for (p = end - ((mlen == -1) ? len : mlen); p <= end; p++)
|
||||
#endif
|
||||
{
|
||||
if (strmatch (pat, p, FNMATCH_EXTFLAG) == 0)
|
||||
{
|
||||
@@ -4160,11 +4134,9 @@ match_upattern (string, pat, mtype, sp, ep)
|
||||
*ep = end;
|
||||
return 1;
|
||||
}
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -4232,22 +4204,14 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
case MATCH_ANY:
|
||||
for (n = 0; n <= wstrlen; n++)
|
||||
{
|
||||
#if 1
|
||||
n2 = simple ? (*wpat == wstring[n]) : match_pattern_wchar (wpat, wstring + n);
|
||||
#else
|
||||
n2 = match_pattern_wchar (wpat, wstring + n);
|
||||
#endif
|
||||
if (n2)
|
||||
{
|
||||
#if 0
|
||||
for (n1 = wstrlen; n1 >= n; n1--)
|
||||
#else
|
||||
n1 = (mlen == -1) ? wstrlen : n + mlen;
|
||||
if (n1 > wstrlen)
|
||||
break;
|
||||
|
||||
for ( ; n1 >= n; n1--)
|
||||
#endif
|
||||
{
|
||||
wc = wstring[n1]; wstring[n1] = L'\0';
|
||||
if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4258,11 +4222,9 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
wstring[n1] = wc;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4273,11 +4235,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
if (match_pattern_wchar (wpat, wstring) == 0)
|
||||
return (0);
|
||||
|
||||
#if 0
|
||||
for (n = wstrlen; n >= 0; n--)
|
||||
#else
|
||||
for (n = (mlen == -1) ? wstrlen : mlen; n >= 0; n--)
|
||||
#endif
|
||||
{
|
||||
wc = wstring[n]; wstring[n] = L'\0';
|
||||
if (wcsmatch (wpat, wstring, FNMATCH_EXTFLAG) == 0)
|
||||
@@ -4288,21 +4246,15 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
return 1;
|
||||
}
|
||||
wstring[n] = wc;
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
case MATCH_END:
|
||||
#if 0
|
||||
for (n = 0; n <= wstrlen; n++)
|
||||
#else
|
||||
for (n = wstrlen - ((mlen == -1) ? wstrlen : mlen); n <= wstrlen; n++)
|
||||
#endif
|
||||
{
|
||||
if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG) == 0)
|
||||
{
|
||||
@@ -4310,11 +4262,9 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
|
||||
*ep = indices[wstrlen];
|
||||
return 1;
|
||||
}
|
||||
#if 1
|
||||
/* If MLEN != -1, we have a fixed length pattern. */
|
||||
if (mlen != -1)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -4344,15 +4294,7 @@ match_pattern (string, pat, mtype, sp, ep)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
#if 0
|
||||
slen = STRLEN (string);
|
||||
mslen = MBSLEN (string);
|
||||
plen = STRLEN (pat);
|
||||
mplen = MBSLEN (pat);
|
||||
if (slen == mslen && plen == mplen)
|
||||
#else
|
||||
if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0)
|
||||
#endif
|
||||
return (match_upattern (string, pat, mtype, sp, ep));
|
||||
|
||||
n = xdupmbstowcs (&wpat, NULL, pat);
|
||||
@@ -5935,7 +5877,10 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
|
||||
else
|
||||
#endif /* ARRAY_VARS */
|
||||
bind_variable (name, t1, 0);
|
||||
stupidly_hack_special_variables (name);
|
||||
#if 0
|
||||
if (STREQ (name, "IFS") == 0)
|
||||
#endif
|
||||
stupidly_hack_special_variables (name);
|
||||
|
||||
/* From Posix group discussion Feb-March 2010. Issue 7 0000221 */
|
||||
free (temp);
|
||||
@@ -6657,18 +6602,7 @@ pos_params_pat_subst (string, pat, rep, mflags)
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
#if 0
|
||||
if ((mflags & (MATCH_QUOTED|MATCH_STARSUB)) == (MATCH_QUOTED|MATCH_STARSUB))
|
||||
ret = string_list_dollar_star (quote_list (save));
|
||||
else if ((mflags & MATCH_STARSUB) == MATCH_STARSUB)
|
||||
ret = string_list_dollar_star (save);
|
||||
else if ((mflags & MATCH_QUOTED) == MATCH_QUOTED)
|
||||
ret = string_list_dollar_at (save, qflags);
|
||||
else
|
||||
ret = string_list_dollar_star (save);
|
||||
#else
|
||||
ret = string_list_pos_params (pchar, save, qflags);
|
||||
#endif
|
||||
|
||||
dispose_words (save);
|
||||
|
||||
@@ -7687,7 +7621,6 @@ param_expand (string, sindex, quoted, expanded_something,
|
||||
an assignment statement. In that case, we don't separate the
|
||||
arguments at all. Otherwise, if the $* is not quoted it is
|
||||
identical to $@ */
|
||||
#if 1
|
||||
# if defined (HANDLE_MULTIBYTE)
|
||||
if (expand_no_split_dollar_star && ifs_firstc[0] == 0)
|
||||
# else
|
||||
@@ -7695,10 +7628,15 @@ param_expand (string, sindex, quoted, expanded_something,
|
||||
# endif
|
||||
temp = string_list_dollar_star (list);
|
||||
else
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
#else
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
#endif
|
||||
{
|
||||
temp = string_list_dollar_at (list, quoted);
|
||||
if (ifs_is_set == 0 || ifs_is_null)
|
||||
{
|
||||
itrace("param_expand: set W_SPLITSPACE flag");
|
||||
tflag |= W_SPLITSPACE;
|
||||
}
|
||||
}
|
||||
|
||||
if (expand_no_split_dollar_star == 0 && contains_dollar_at)
|
||||
*contains_dollar_at = 1;
|
||||
}
|
||||
@@ -8060,6 +7998,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
|
||||
/* State flags */
|
||||
int had_quoted_null;
|
||||
int has_dollar_at, temp_has_dollar_at;
|
||||
int split_on_spaces;
|
||||
int tflag;
|
||||
int pflags; /* flags passed to param_expand */
|
||||
|
||||
@@ -8075,6 +8014,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
|
||||
istring = (char *)xmalloc (istring_size = DEFAULT_INITIAL_ARRAY_SIZE);
|
||||
istring[istring_index = 0] = '\0';
|
||||
quoted_dollar_at = had_quoted_null = has_dollar_at = 0;
|
||||
split_on_spaces = 0;
|
||||
quoted_state = UNQUOTED;
|
||||
|
||||
string = word->word;
|
||||
@@ -8275,6 +8215,10 @@ add_string:
|
||||
&had_quoted_null, pflags);
|
||||
has_dollar_at += temp_has_dollar_at;
|
||||
|
||||
split_on_spaces += (tword->flags & W_SPLITSPACE);
|
||||
if (tword->flags & W_SPLITSPACE)
|
||||
itrace("expand_word_internal: param_expand return word has W_SPLITSPACE");
|
||||
|
||||
if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal)
|
||||
{
|
||||
free (string);
|
||||
@@ -8403,11 +8347,7 @@ add_twochars:
|
||||
break;
|
||||
|
||||
case '"':
|
||||
#if 0
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE))
|
||||
#else
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
|
||||
#endif
|
||||
goto add_character;
|
||||
|
||||
t_index = ++sindex;
|
||||
@@ -8495,11 +8435,6 @@ add_twochars:
|
||||
{
|
||||
if (list->next)
|
||||
{
|
||||
#if 0
|
||||
if (quoted_dollar_at && (word->flags & W_NOSPLIT2))
|
||||
temp = string_list_internal (quote_list (list), " ");
|
||||
else
|
||||
#endif
|
||||
/* Testing quoted_dollar_at makes sure that "$@" is
|
||||
split correctly when $IFS does not contain a space. */
|
||||
temp = quoted_dollar_at
|
||||
@@ -8562,11 +8497,7 @@ add_twochars:
|
||||
/* break; */
|
||||
|
||||
case '\'':
|
||||
#if 0
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (word->flags & W_DQUOTE))
|
||||
#else
|
||||
if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
|
||||
#endif
|
||||
goto add_character;
|
||||
|
||||
t_index = ++sindex;
|
||||
@@ -8900,6 +8831,9 @@ setifs (v)
|
||||
ifs_var = v;
|
||||
ifs_value = (v && value_cell (v)) ? value_cell (v) : " \t\n";
|
||||
|
||||
ifs_is_set = ifs_var != 0;
|
||||
ifs_is_null = ifs_is_set && (*ifs_value == 0);
|
||||
|
||||
/* Should really merge ifs_cmap with sh_syntaxtab. XXX - doesn't yet
|
||||
handle multibyte chars in IFS */
|
||||
memset (ifs_cmap, '\0', sizeof (ifs_cmap));
|
||||
@@ -9212,7 +9146,6 @@ glob_expand_word_list (tlist, eflags)
|
||||
for (glob_index = 0; glob_array[glob_index]; glob_index++)
|
||||
{
|
||||
tword = make_bare_word (glob_array[glob_index]);
|
||||
tword->flags |= W_GLOBEXP; /* XXX */
|
||||
glob_list = make_word_list (tword, glob_list);
|
||||
}
|
||||
|
||||
@@ -9487,6 +9420,7 @@ expand_word_list_internal (list, eflags)
|
||||
WORD_LIST *new_list, *temp_list;
|
||||
int tint;
|
||||
|
||||
tempenv_assign_error = 0;
|
||||
if (list == 0)
|
||||
return ((WORD_LIST *)NULL);
|
||||
|
||||
@@ -9592,13 +9526,5 @@ expand_word_list_internal (list, eflags)
|
||||
subst_assign_varlist = (WORD_LIST *)NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
tint = list_length (new_list) + 1;
|
||||
RESIZE_MALLOCED_BUFFER (glob_argv_flags, 0, tint, glob_argv_flags_size, 16);
|
||||
for (tint = 0, temp_list = new_list; temp_list; temp_list = temp_list->next)
|
||||
glob_argv_flags[tint++] = (temp_list->word->flags & W_GLOBEXP) ? '1' : '0';
|
||||
glob_argv_flags[tint] = '\0';
|
||||
#endif
|
||||
|
||||
return (new_list);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
export THIS_SH PATH
|
||||
|
||||
rm -f /tmp/xx
|
||||
|
||||
/bin/sh "$@"
|
||||
-27
@@ -4108,33 +4108,6 @@ put_command_name_into_env (command_name)
|
||||
update_export_env_inplace ("_=", 2, command_name);
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED -- it caused too many problems */
|
||||
void
|
||||
put_gnu_argv_flags_into_env (pid, flags_string)
|
||||
intmax_t pid;
|
||||
char *flags_string;
|
||||
{
|
||||
char *dummy, *pbuf;
|
||||
int l, fl;
|
||||
|
||||
pbuf = itos (pid);
|
||||
l = strlen (pbuf);
|
||||
|
||||
fl = strlen (flags_string);
|
||||
|
||||
dummy = (char *)xmalloc (l + fl + 30);
|
||||
dummy[0] = '_';
|
||||
strcpy (dummy + 1, pbuf);
|
||||
strcpy (dummy + 1 + l, "_GNU_nonoption_argv_flags_");
|
||||
dummy[l + 27] = '=';
|
||||
strcpy (dummy + l + 28, flags_string);
|
||||
|
||||
free (pbuf);
|
||||
|
||||
export_env = add_or_supercede_exported_var (dummy, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Managing variable contexts */
|
||||
|
||||
+5243
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user