diff --git a/Makefile.in b/Makefile.in index 24c646a..c7b62bc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -77,7 +77,6 @@ AR = @AR@ ARFLAGS = @ARFLAGS@ RANLIB = @RANLIB@ SIZE = @SIZE@ -STRIP = strip INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -593,7 +592,7 @@ bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile $(VERSPROG) @chmod a+rx bashbug strip: $(Program) .made - $(STRIP) $(Program) + strip $(Program) ls -l $(Program) -$(SIZE) $(Program) @@ -800,6 +799,7 @@ install: .made installdirs infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) -( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) install-strip: $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ diff --git a/aclocal.m4 b/aclocal.m4 index c815f5c..d3bac07 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1284,7 +1284,7 @@ main() wait(&status); exit(ok ? 0 : 5); } -], bash_cv_pgrp_pipe=yes,bash_cv_pgrp_pipe=yes, +], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no) bash_cv_pgrp_pipe=no]) ]) diff --git a/bashhist.c b/bashhist.c index 793c81f..9979f99 100644 --- a/bashhist.c +++ b/bashhist.c @@ -754,12 +754,6 @@ extern char *shell_name; #define OPENLOG_OPTS 0 #endif -#if defined (SYSLOG_SHOPT) -int syslog_history = SYSLOG_SHOPT; -#else -int syslog_history = 1; -#endif - void bash_syslog_history (line) const char *line; @@ -857,8 +851,7 @@ bash_add_history (line) really_add_history (line); #if defined (SYSLOG_HISTORY) - if (syslog_history) - bash_syslog_history (line); + bash_syslog_history (line); #endif using_history (); diff --git a/bashline.c b/bashline.c index 0275844..f4fe9f1 100644 --- a/bashline.c +++ b/bashline.c @@ -142,7 +142,7 @@ static int executable_completion __P((const char *, int)); static rl_icppfunc_t *save_directory_hook __P((void)); static void restore_directory_hook __P((rl_icppfunc_t)); -static int directory_exists __P((const char *, int)); +static int directory_exists __P((const char *)); static void cleanup_expansion_error __P((void)); static void maybe_make_readline_line __P((char *)); @@ -3102,20 +3102,18 @@ restore_directory_hook (hookf) rl_directory_rewrite_hook = hookf; } -/* Check whether not DIRNAME, with any trailing slash removed, exists. If - SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */ +/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash + removed, exists. */ static int -directory_exists (dirname, should_dequote) +directory_exists (dirname) const char *dirname; - int should_dequote; { char *new_dirname; int dirlen, r; struct stat sb; - /* We save the string and chop the trailing slash because stat/lstat behave - inconsistently if one is present. */ - new_dirname = should_dequote ? bash_dequote_filename ((char *)dirname, rl_completion_quote_character) : savestring (dirname); + /* First, dequote the directory name */ + new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character); dirlen = STRLEN (new_dirname); if (new_dirname[dirlen - 1] == '/') new_dirname[dirlen - 1] = '\0'; @@ -3147,7 +3145,7 @@ bash_filename_stat_hook (dirname) else if (t = mbschr (local_dirname, '`')) /* XXX */ should_expand_dirname = '`'; - if (should_expand_dirname && directory_exists (local_dirname, 0)) + if (should_expand_dirname && directory_exists (local_dirname)) should_expand_dirname = 0; if (should_expand_dirname) @@ -3157,7 +3155,7 @@ bash_filename_stat_hook (dirname) have to worry about restoring this setting. */ global_nounset = unbound_vars_is_error; unbound_vars_is_error = 0; - wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */ + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */ unbound_vars_is_error = global_nounset; if (wl) { @@ -3246,13 +3244,13 @@ bash_directory_completion_hook (dirname) should_expand_dirname = '`'; } - if (should_expand_dirname && directory_exists (local_dirname, 1)) + if (should_expand_dirname && directory_exists (local_dirname)) should_expand_dirname = 0; if (should_expand_dirname) { new_dirname = savestring (local_dirname); - wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */ + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */ if (wl) { *dirname = string_list (wl); diff --git a/builtins.h b/builtins.h index a6ef958..0cfea18 100644 --- a/builtins.h +++ b/builtins.h @@ -42,7 +42,6 @@ #define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */ #define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */ #define LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */ -#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */ #define BASE_INDENT 4 diff --git a/builtins/Makefile.in b/builtins/Makefile.in index f1e9e2e..bbb96c3 100644 --- a/builtins/Makefile.in +++ b/builtins/Makefile.in @@ -117,6 +117,7 @@ RL_LIBSRC = $(topdir)/lib/readline $(RM) $@ ./$(MKBUILTINS) $(DIRECTDEFINE) $< $(CC) -c $(CCFLAGS) $*.c || ( $(RM) $*.c ; exit 1 ) + $(RM) $*.c # How to make a .c file from a .def file. .def.c: diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 6dc756c..e221591 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -104,9 +104,12 @@ should_suppress_fork (command) running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && +#if 0 signal_is_trapped (EXIT_TRAP) == 0 && signal_is_trapped (ERROR_TRAP) == 0 && +#else any_signals_trapped () < 0 && +#endif command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & CMD_TIME_PIPELINE) == 0) && ((command->flags & CMD_INVERT_RETURN) == 0)); diff --git a/builtins/fc.def b/builtins/fc.def index 98c53db..fe16471 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -423,7 +423,6 @@ fc_builtin (list) { sh_wrerror (); fclose (stream); - FREE (fn); return (EXECUTION_FAILURE); } fclose (stream); diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c index 1867973..4f51201 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -69,15 +69,10 @@ extern char *strcpy (); #define whitespace(c) (((c) == ' ') || ((c) == '\t')) /* Flag values that builtins can have. */ -/* These flags are for the C code generator, - the C which is produced (./builtin.c) - includes the flags definitions found - in ../builtins.h */ #define BUILTIN_FLAG_SPECIAL 0x01 #define BUILTIN_FLAG_ASSIGNMENT 0x02 #define BUILTIN_FLAG_LOCALVAR 0x04 #define BUILTIN_FLAG_POSIX_BUILTIN 0x08 -#define BUILTIN_FLAG_REQUIRES 0x10 #define BASE_INDENT 4 @@ -178,20 +173,11 @@ char *posix_builtins[] = (char *)NULL }; -/* The builtin commands that cause requirements on other files. */ -static char *requires_builtins[] = -{ - ".", "command", "exec", "source", "inlib", - (char *)NULL -}; - - /* Forward declarations. */ static int is_special_builtin (); static int is_assignment_builtin (); static int is_localvar_builtin (); static int is_posix_builtin (); -static int is_requires_builtin (); #if !defined (HAVE_RENAME) static int rename (); @@ -845,9 +831,6 @@ builtin_handler (self, defs, arg) new->flags |= BUILTIN_FLAG_LOCALVAR; if (is_posix_builtin (name)) new->flags |= BUILTIN_FLAG_POSIX_BUILTIN; - if (is_requires_builtin (name)) - new->flags |= BUILTIN_FLAG_REQUIRES; - array_add ((char *)new, defs->builtins); building_builtin = 1; @@ -1267,13 +1250,12 @@ write_builtins (defs, structfile, externfile) else fprintf (structfile, "(sh_builtin_func_t *)0x0, "); - fprintf (structfile, "%s%s%s%s%s%s, %s_doc,\n", + fprintf (structfile, "%s%s%s%s%s, %s_doc,\n", "BUILTIN_ENABLED | STATIC_BUILTIN", (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "", (builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "", - (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "", document_name (builtin)); /* Don't translate short document summaries that are identical @@ -1663,13 +1645,6 @@ is_posix_builtin (name) return (_find_in_table (name, posix_builtins)); } -static int -is_requires_builtin (name) - char *name; -{ - return (_find_in_table (name, requires_builtins)); -} - #if !defined (HAVE_RENAME) static int rename (from, to) diff --git a/builtins/pushd.def b/builtins/pushd.def index 6579e4c..82653c4 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -365,7 +365,7 @@ popd_builtin (list) break; } - if (which > directory_list_offset || (which < -directory_list_offset) || (directory_list_offset == 0 && which == 0)) + if (which > directory_list_offset || (directory_list_offset == 0 && which == 0)) { pushd_error (directory_list_offset, which_word ? which_word : ""); return (EXECUTION_FAILURE); @@ -387,11 +387,6 @@ popd_builtin (list) remove that directory from the list and shift the remainder of the list into place. */ i = (direction == '+') ? directory_list_offset - which : which; - if (i < 0 || i > directory_list_offset) - { - pushd_error (directory_list_offset, which_word ? which_word : ""); - return (EXECUTION_FAILURE); - } free (pushd_directory_list[i]); directory_list_offset--; diff --git a/builtins/read.def b/builtins/read.def index b54b3af..48fda33 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -181,8 +181,7 @@ read_builtin (list) WORD_LIST *list; { register char *varname; - int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; - volatile int i; + int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; int raw, edit, nchars, silent, have_timeout, ignore_delim, fd, lastsig, t_errno; unsigned int tmsec, tmusec; @@ -610,7 +609,7 @@ read_builtin (list) } CHECK_ALRM; - QUIT; /* in case we didn't call check_signals() */ + #if defined (READLINE) } #endif @@ -690,11 +689,6 @@ add_char: input_string[i] = '\0'; CHECK_ALRM; -#if defined (READLINE) - if (edit) - free (rlbuf); -#endif - if (retval < 0) { t_errno = errno; diff --git a/builtins/setattr.def b/builtins/setattr.def index 314fceb..8f29e11 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -611,7 +611,4 @@ set_var_attribute (name, attribute, undo) if (var && (exported_p (var) || (attribute & att_exported))) array_needs_making++; /* XXX */ - - if (var) - stupidly_hack_special_variables (name); } diff --git a/builtins/shopt.def b/builtins/shopt.def index 38c398e..2febb7e 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -118,10 +118,6 @@ extern char *shell_name; extern int debugging_mode; #endif -#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT) -extern int syslog_history; -#endif - static void shopt_error __P((char *)); static int set_shellopts_after_change __P((char *, int)); @@ -227,9 +223,6 @@ static struct { #endif { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL }, { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL }, -#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT) - { "syslog_history", &syslog_history, (shopt_set_func_t *)NULL }, -#endif { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL }, { (char *)0, (int *)0, (shopt_set_func_t *)NULL } }; diff --git a/config-top.h b/config-top.h index 39cf6b5..d89682e 100644 --- a/config-top.h +++ b/config-top.h @@ -23,8 +23,6 @@ what POSIX.2 specifies. */ #define CONTINUE_AFTER_KILL_ERROR -#define NON_INTERACTIVE_LOGIN_SHELLS - /* Define BREAK_COMPLAINS if you want the non-standard, but useful error messages about `break' and `continue' out of context. */ #define BREAK_COMPLAINS @@ -60,7 +58,7 @@ /* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins like `echo' and `printf' to report errors when output does not succeed due to EPIPE. */ -#define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS +/* #define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS */ /* The default value of the PATH variable. */ #ifndef DEFAULT_PATH_VALUE @@ -72,7 +70,7 @@ the Posix.2 confstr () function, or CS_PATH define are not present. */ #ifndef STANDARD_UTILS_PATH #define STANDARD_UTILS_PATH \ - "/bin:/usr/bin:/usr/sbin:/sbin" + "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" #endif /* Default primary and secondary prompt strings. */ @@ -92,7 +90,7 @@ /* #define SYS_BASHRC "/etc/bash.bashrc" */ /* System-wide .bash_logout for login shells. */ -#define SYS_BASH_LOGOUT "/etc/bash.bash_logout" +/* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */ /* Define this to make non-interactive shells begun with argv[0][0] == '-' run the startup files when not in posix mode. */ @@ -102,7 +100,7 @@ sshd and source the .bashrc if so (like the rshd behavior). This checks for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment, which can be fooled under certain not-uncommon circumstances. */ -#define SSH_SOURCE_BASHRC +/* #define SSH_SOURCE_BASHRC */ /* Define if you want the case-capitalizing operators (~[~]) and the `capcase' variable attribute (declare -c). */ @@ -122,13 +120,6 @@ # define OPENLOG_OPTS LOG_PID #endif -/* Define if you want syslogging history to be controllable at runtime via a - shell option; if defined, the value is the default for the syslog_history - shopt option */ -#if defined (SYSLOG_HISTORY) -#define SYSLOG_SHOPT 0 -#endif - /* Define if you want to include code in shell.c to support wordexp(3) */ /* #define WORDEXP_OPTION */ diff --git a/config.h.in b/config.h.in index 1a89e85..a5ad9e7 100644 --- a/config.h.in +++ b/config.h.in @@ -449,7 +449,6 @@ #undef SYS_TIME_H_DEFINES_STRUCT_TIMESPEC #undef PTHREAD_H_DEFINES_STRUCT_TIMESPEC -#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC #undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC #undef HAVE_STRUCT_STAT_ST_ATIMENSEC @@ -749,9 +748,6 @@ /* Define if you have the pselect function. */ #undef HAVE_PSELECT -/* Define if you have the pread function. */ -#undef HAVE_PREAD - /* Define if you have the putenv function. */ #undef HAVE_PUTENV @@ -950,9 +946,6 @@ /* Define if you have the header file. */ #undef HAVE_DLFCN_H -/* Define if you have the header file. */ -#undef HAVE_ELF_H - /* Define if you have the header file. */ #undef HAVE_GRP_H @@ -1191,14 +1184,6 @@ /* End additions for lib/intl */ - -/* Additions for lib/readline */ - -/* Define if you have and it defines AUDIT_USER_TTY */ -#undef HAVE_DECL_AUDIT_USER_TTY - -/* End additions for lib/readline */ - #include "config-bot.h" #endif /* _CONFIG_H_ */ diff --git a/configure.ac b/configure.ac index a3f6d8f..ce4e9b6 100644 --- a/configure.ac +++ b/configure.ac @@ -700,7 +700,7 @@ BASH_HEADER_INTTYPES AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \ memory.h locale.h termcap.h termio.h termios.h dlfcn.h \ stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ - regex.h syslog.h ulimit.h elf.h) + regex.h syslog.h ulimit.h) AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \ sys/param.h sys/socket.h sys/stat.h \ sys/time.h sys/times.h sys/types.h sys/wait.h) @@ -771,7 +771,7 @@ dnl checks for system calls AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \ getpagesize getpeername getrlimit getrusage gettimeofday \ kill killpg lstat pselect readlink sbrk select setdtablesize \ - setitimer tcgetpgrp uname ulimit waitpid pread) + setitimer tcgetpgrp uname ulimit waitpid) AC_REPLACE_FUNCS(rename) dnl checks for c library functions @@ -942,8 +942,6 @@ BASH_FUNC_DUP2_CLOEXEC_CHECK BASH_SYS_PGRP_SYNC BASH_SYS_SIGNAL_VINTAGE -AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include ]]) - dnl checking for the presence of certain library symbols BASH_SYS_ERRLIST BASH_SYS_SIGLIST diff --git a/doc/Makefile.in b/doc/Makefile.in index a5fa5a0..5f0756c 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -74,6 +74,7 @@ TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html MAN2HTML = ${BUILD_DIR}/support/man2html HTMLPOST = ${srcdir}/htmlpost.sh +INFOPOST = ${srcdir}/infopost.sh QUIETPS = #set this to -q to shut up dvips PAPERSIZE = letter # change to a4 for A4-size paper PSDPI = 600 # could be 300 if you like @@ -187,8 +188,8 @@ bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER) bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER) $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi -bash.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER) - $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi -o $@ +bash.info: bashref.info + ${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \ bash.txt: bash.1 bash.ps: bash.1 diff --git a/doc/bash.1 b/doc/bash.1 index 9dfa0b3..9a7a384 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -238,14 +238,6 @@ The shell becomes restricted (see .B "RESTRICTED SHELL" below). .TP -.B \-\-rpm-requires -Produce the list of files that are required for the -shell script to run. This implies '-n' and is subject -to the same limitations as compile time error checking checking; -Command substitutions, Conditional expressions and -.BR eval -builtin are not parsed so some dependencies may be missed. -.TP .B \-\-verbose Equivalent to \fB\-v\fP. .TP @@ -335,8 +327,8 @@ option may be used when the shell is started to inhibit this behavior. When an interactive login shell exits, or a non-interactive login shell executes the \fBexit\fP builtin command, .B bash -reads and executes commands from the files \fI~/.bash_logout\fP -and \fI/etc/bash.bash_logout\fP, if the files exists. +reads and executes commands from the file \fI~/.bash_logout\fP, if it +exists. .PP When an interactive shell that is not a login shell is started, .B bash @@ -9889,9 +9881,6 @@ If set, the to find the directory containing the file supplied as an argument. This option is enabled by default. .TP 8 -.B syslog_history -If set, command history is logged to syslog. -.TP 8 .B xpg_echo If set, the \fBecho\fP builtin expands backslash-escape sequences by default. @@ -10129,7 +10118,7 @@ being inverted using These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. .if t .sp 0.5 .if n .sp 1 -Signals ignored upon entry to the shell cannot be trapped, reset or listed. +Signals ignored upon entry to the shell cannot be trapped or reset. Trapped signals that are not being ignored are reset to their original values in a subshell or subshell environment when one is created. The return status is false if any @@ -10336,7 +10325,6 @@ and which are in 512-byte increments. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit. -In POSIX Mode 512-byte blocks are used for the `-c' and `-f' options. .RE .TP \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] @@ -10562,9 +10550,6 @@ The \fBbash\fP executable .FN /etc/profile The systemwide initialization file, executed for login shells .TP -.FN /etc/bash.bash_logout -The systemwide login shell cleanup file, executed when a login shell exits -.TP .FN ~/.bash_profile The personal initialization file, executed for login shells .TP diff --git a/doc/bashref.texi b/doc/bashref.texi index 8e30d4f..c0f4a2f 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -6243,13 +6243,6 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash @item --restricted Make the shell a restricted shell (@pxref{The Restricted Shell}). -@item --rpm-requires -Produce the list of files that are required for the -shell script to run. This implies '-n' and is subject -to the same limitations as compile time error checking checking; -Command substitutions, Conditional expressions and @command{eval} -are not parsed so some dependencies may be missed. - @item --verbose Equivalent to @option{-v}. Print shell input lines as they're read. diff --git a/doc/builtins.1 b/doc/builtins.1 index dde1bbe..829a49c 100644 --- a/doc/builtins.1 +++ b/doc/builtins.1 @@ -19,6 +19,6 @@ shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1) .SH BASH BUILTIN COMMANDS .nr zZ 1 -.so man1/bash.1 +.so bash.1 .SH SEE ALSO bash(1), sh(1) diff --git a/eval.c b/eval.c index 5a5af32..db863e7 100644 --- a/eval.c +++ b/eval.c @@ -56,7 +56,6 @@ extern int need_here_doc; extern int current_command_number, current_command_line_count, line_number; extern int expand_aliases; extern char *ps0_prompt; -extern int rpm_requires; #if defined (HAVE_POSIX_SIGNALS) extern sigset_t top_level_mask; @@ -149,7 +148,7 @@ reader_loop () if (read_command () == 0) { - if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires)) + if (interactive_shell == 0 && read_but_dont_execute) { last_command_exit_value = EXECUTION_SUCCESS; dispose_command (global_command); diff --git a/examples/loadables/Makefile.in b/examples/loadables/Makefile.in index de2e020..ec305cd 100644 --- a/examples/loadables/Makefile.in +++ b/examples/loadables/Makefile.in @@ -58,7 +58,7 @@ host_os = @host_os@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ -CFLAGS = -O2 -g +CFLAGS = @CFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@ DEFS = @DEFS@ LOCAL_DEFS = @LOCAL_DEFS@ diff --git a/examples/loadables/perl/Makefile.in b/examples/loadables/perl/Makefile.in index aa93b50..59f39b6 100644 --- a/examples/loadables/perl/Makefile.in +++ b/examples/loadables/perl/Makefile.in @@ -42,7 +42,7 @@ SHELL = @MAKE_SHELL@ PERL5 = perl5 -CFLAGS = -O2 -g +CFLAGS = @CFLAGS@ # # These values are generated for configure by ${topdir}/support/shobj-conf. diff --git a/execute_cmd.c b/execute_cmd.c index 15b5e19..2a3df6d 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -41,10 +41,6 @@ # include #endif -#ifdef HAVE_ELF_H -# include -#endif - #include "posixtime.h" #if defined (HAVE_SYS_RESOURCE_H) && !defined (RLIMTYPE) @@ -533,8 +529,6 @@ async_redirect_stdin () #define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0) -extern int rpm_requires; - /* Execute the command passed in COMMAND, perhaps doing it asynchronously. COMMAND is exactly what read_command () places into GLOBAL_COMMAND. ASYNCHROUNOUS, if non-zero, says to do this command in the background. @@ -567,13 +561,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, if (breaking || continuing) return (last_command_exit_value); - if (command == 0 || (read_but_dont_execute && !rpm_requires)) - return (EXECUTION_SUCCESS); - if (rpm_requires && command->type == cm_function_def) - return last_command_exit_value = - execute_intern_function (command->value.Function_def->name, - command->value.Function_def); - if (read_but_dont_execute) + if (command == 0 || read_but_dont_execute) return (EXECUTION_SUCCESS); QUIT; @@ -738,8 +726,6 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, { ofifo = num_fifos (); ofifo_list = copy_fifo_list ((int *)&osize); - begin_unwind_frame ("internal_fifos"); - add_unwind_protect (xfree, ofifo_list); saved_fifo = 1; } else @@ -755,10 +741,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, dispose_exec_redirects (); #if defined (PROCESS_SUBSTITUTION) if (saved_fifo) - { - free ((void *)ofifo_list); - discard_unwind_frame ("internal_fifos"); - } + free ((void *)ofifo_list); #endif return (last_command_exit_value = EXECUTION_FAILURE); } @@ -1077,7 +1060,6 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, if (nfifo > ofifo) close_new_fifos ((char *)ofifo_list, osize); free ((void *)ofifo_list); - discard_unwind_frame ("internal_fifos"); } #endif @@ -2196,10 +2178,8 @@ coproc_setvars (cp) if (v == 0) { v = find_variable_nameref_for_create (cp->c_name, 1); - if (v == INVALID_NAMEREF_VALUE) { - free (namevar); - return; - } + if (v == INVALID_NAMEREF_VALUE) + return; if (v && nameref_p (v)) { free (cp->c_name); @@ -2212,7 +2192,6 @@ coproc_setvars (cp) { if (readonly_p (v)) err_readonly (cp->c_name); - free (namevar); return; } if (v == 0) @@ -4998,14 +4977,9 @@ execute_builtin_or_function (words, builtin, var, redirects, char *ofifo_list; #endif -#if defined (PROCESS_SUBSTITUTION) - begin_unwind_frame ("saved_fifos"); - /* If we return, we longjmp and don't get a chance to restore the old - fifo list, so we add an unwind protect to free it */ +#if defined (PROCESS_SUBSTITUTION) ofifo = num_fifos (); ofifo_list = copy_fifo_list (&osize); - if (ofifo_list) - add_unwind_protect (xfree, ofifo_list); #endif if (do_redirections (redirects, RX_ACTIVE|RX_UNDOABLE) != 0) @@ -5089,9 +5063,7 @@ execute_builtin_or_function (words, builtin, var, redirects, nfifo = num_fifos (); if (nfifo > ofifo) close_new_fifos (ofifo_list, osize); - if (ofifo_list) - free (ofifo_list); - discard_unwind_frame ("saved_fifos"); + free (ofifo_list); #endif return (result); @@ -5514,14 +5486,6 @@ shell_execve (command, args, env) { /* The file has the execute bits set, but the kernel refuses to run it for some reason. See why. */ -#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H) - int fd = open (command, O_RDONLY); - - if (fd >= 0) - sample_len = read (fd, sample, sizeof (sample)); - else - sample_len = -1; -#endif #if defined (HAVE_HASH_BANG_EXEC) READ_SAMPLE_BUF (command, sample, sample_len); if (sample_len > 0) @@ -5546,240 +5510,6 @@ shell_execve (command, args, env) return (EX_NOEXEC); } #endif -#if defined (HAVE_ELF_H) - if (i == ENOENT - && sample_len > EI_NIDENT - && memcmp (sample, ELFMAG, SELFMAG) == 0) - { - off_t offset = -1; - int dynamic_nobits = 0; - - /* It is an ELF file. Now determine whether it is dynamically - linked and if yes, get the offset of the interpreter - string. */ - if (sample[EI_CLASS] == ELFCLASS32 - && sample_len > sizeof (Elf32_Ehdr)) - { - Elf32_Ehdr ehdr; - Elf32_Phdr *phdr; - Elf32_Shdr *shdr; - Elf32_Half nphdr, nshdr; - - /* We have to copy the data since the sample buffer - might not be aligned correctly to be accessed as - an Elf32_Ehdr struct. */ - memcpy (&ehdr, sample, sizeof (Elf32_Ehdr)); - - nshdr = ehdr.e_shnum; - shdr = (Elf32_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize); - - if (shdr != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize, - ehdr.e_shoff); -#else - if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) - sample_len = read (fd, shdr, - nshdr * ehdr.e_shentsize); - else - sample_len = -1; -#endif - if (sample_len == nshdr * ehdr.e_shentsize) - { - char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size); - if (strings != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, strings, - shdr[ehdr.e_shstrndx].sh_size, - shdr[ehdr.e_shstrndx].sh_offset); -#else - if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset, - SEEK_SET) != -1) - sample_len = read (fd, strings, - shdr[ehdr.e_shstrndx].sh_size); - else - sample_len = -1; -#endif - if (sample_len == shdr[ehdr.e_shstrndx].sh_size) - while (nshdr-- > 0) - if (strcmp (strings + shdr[nshdr].sh_name, - ".interp") == 0 && - shdr[nshdr].sh_type == SHT_NOBITS) - { - dynamic_nobits++; - break; - } - free (strings); - } - } - free (shdr); - } - - nphdr = ehdr.e_phnum; - phdr = (Elf32_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize); - if (phdr != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize, - ehdr.e_phoff); -#else - if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) - sample_len = read (fd, phdr, - nphdr * ehdr.e_phentsize); - else - sample_len = -1; -#endif - if (sample_len == nphdr * ehdr.e_phentsize) - while (nphdr-- > 0) - if (phdr[nphdr].p_type == PT_INTERP) - { - offset = phdr[nphdr].p_offset; - break; - } - free (phdr); - } - } - else if (sample[EI_CLASS] == ELFCLASS64 - && sample_len > sizeof (Elf64_Ehdr)) - { - Elf64_Ehdr ehdr; - Elf64_Phdr *phdr; - Elf64_Shdr *shdr; - Elf32_Half nphdr, nshdr; - - /* We have to copy the data since the sample buffer - might not be aligned correctly to be accessed as - an Elf64_Ehdr struct. */ - memcpy (&ehdr, sample, sizeof (Elf64_Ehdr)); - - nshdr = ehdr.e_shnum; - shdr = (Elf64_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize); - if (shdr != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize, - ehdr.e_shoff); -#else - if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) - sample_len = read (fd, shdr, - nshdr * ehdr.e_shentsize); - else - sample_len = -1; -#endif - if (sample_len == nshdr * ehdr.e_shentsize) - { - char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size); - if (strings != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, strings, - shdr[ehdr.e_shstrndx].sh_size, - shdr[ehdr.e_shstrndx].sh_offset); -#else - if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset, - SEEK_SET) != -1) - sample_len = read (fd, strings, - shdr[ehdr.e_shstrndx].sh_size); - else - sample_len = -1; -#endif - if (sample_len == shdr[ehdr.e_shstrndx].sh_size) - while (nshdr-- > 0) - if (strcmp (strings + shdr[nshdr].sh_name, - ".interp") == 0 && - shdr[nshdr].sh_type == SHT_NOBITS) - { - dynamic_nobits++; - break; - } - free (strings); - } - } - free (shdr); - } - - nphdr = ehdr.e_phnum; - phdr = (Elf64_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize); - if (phdr != NULL) - { -#ifdef HAVE_PREAD - sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize, - ehdr.e_phoff); -#else - if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) - sample_len = read (fd, phdr, - nphdr * ehdr.e_phentsize); - else - sample_len = -1; -#endif - if (sample_len == nphdr * ehdr.e_phentsize) - while (nphdr-- > 0) - if (phdr[nphdr].p_type == PT_INTERP) - { - offset = phdr[nphdr].p_offset; - break; - } - free (phdr); - } - } - - if (offset != -1) - { - ssize_t maxlen = 0; - ssize_t actlen = 0; - char *interp = NULL; - - do - { - if (actlen == maxlen) - { - char *newinterp = realloc (interp, maxlen += 200); - if (newinterp == NULL) - { - actlen = 0; - break; - } - interp = newinterp; - -#ifdef HAVE_PREAD - actlen = pread (fd, interp, maxlen, offset); -#else - if (lseek (fd, offset, SEEK_SET) != -1) - actlen = read (fd, interp, maxlen); - else - actlen = -1; -#endif - } - } - while (actlen > 0 && memchr (interp, '\0', actlen) == NULL); - - if (actlen > 0) - { - close (fd); - errno = i; - if (dynamic_nobits > 0) - { - sys_error ("%s: bad ELF interpreter", command); - } - else - { - sys_error ("%s: %s: bad ELF interpreter", command, - interp); - } - free (interp); - return (EX_NOEXEC); - } - - free (interp); - } - } -#endif -#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H) - if (fd >= 0) - close (fd); -#endif errno = i; file_error (command); } @@ -5879,7 +5609,7 @@ execute_intern_function (name, funcdef) if (check_identifier (name, posixly_correct) == 0) { - if (posixly_correct && interactive_shell == 0 && rpm_requires == 0) + if (posixly_correct && interactive_shell == 0) { last_command_exit_value = EX_BADUSAGE; jump_to_top_level (ERREXIT); diff --git a/execute_cmd.h b/execute_cmd.h index 439f91a..62bec82 100644 --- a/execute_cmd.h +++ b/execute_cmd.h @@ -22,8 +22,6 @@ #define _EXECUTE_CMD_H_ #include "stdc.h" -#include "variables.h" -#include "command.h" #if defined (ARRAY_VARS) struct func_array_state @@ -37,9 +35,6 @@ struct func_array_state }; #endif -/* Variables delared in execute_cmd.c, used by many other files */ -extern int executing_command_builtin; - extern struct fd_bitmap *new_fd_bitmap __P((int)); extern void dispose_fd_bitmap __P((struct fd_bitmap *)); extern void close_fd_bitmap __P((struct fd_bitmap *)); diff --git a/expr.c b/expr.c index 5dc57c0..1ddb693 100644 --- a/expr.c +++ b/expr.c @@ -207,8 +207,7 @@ static intmax_t exp5 __P((void)); static intmax_t exp4 __P((void)); static intmax_t expshift __P((void)); static intmax_t exp3 __P((void)); -/* Avoid name clash with standard exp2 */ -static intmax_t bash_exp2 __P((void)); +static intmax_t exp2 __P((void)); static intmax_t exppower __P((void)); static intmax_t exp1 __P((void)); static intmax_t exp0 __P((void)); @@ -579,23 +578,24 @@ expcond () rval = cval = explor (); if (curtok == QUES) /* found conditional expr */ { + readtok (); + if (curtok == 0 || curtok == COL) + evalerror (_("expression expected")); if (cval == 0) { set_noeval = 1; noeval++; } - readtok (); - if (curtok == 0 || curtok == COL) - evalerror (_("expression expected")); - val1 = EXP_HIGHEST (); if (set_noeval) noeval--; if (curtok != COL) evalerror (_("`:' expected for conditional expression")); - + readtok (); + if (curtok == 0) + evalerror (_("expression expected")); set_noeval = 0; if (cval) { @@ -603,11 +603,7 @@ expcond () noeval++; } - readtok (); - if (curtok == 0) - evalerror (_("expression expected")); val2 = expcond (); - if (set_noeval) noeval--; rval = cval ? val1 : val2; @@ -810,14 +806,14 @@ exp3 () { register intmax_t val1, val2; - val1 = bash_exp2 (); + val1 = exp2 (); while ((curtok == PLUS) || (curtok == MINUS)) { int op = curtok; readtok (); - val2 = bash_exp2 (); + val2 = exp2 (); if (op == PLUS) val1 += val2; @@ -829,7 +825,7 @@ exp3 () } static intmax_t -bash_exp2 () +exp2 () { register intmax_t val1, val2; #if defined (HAVE_IMAXDIV) diff --git a/jobs.c b/jobs.c index 4e951fa..cef3c79 100644 --- a/jobs.c +++ b/jobs.c @@ -453,21 +453,6 @@ cleanup_the_pipeline () discard_pipeline (disposer); } -void -discard_last_procsub_child () -{ - PROCESS *disposer; - sigset_t set, oset; - - BLOCK_CHILD (set, oset); - disposer = last_procsub_child; - last_procsub_child = (PROCESS *)NULL; - UNBLOCK_CHILD (oset); - - if (disposer) - discard_pipeline (disposer); -} - struct pipeline_saver * alloc_pipeline_saver () { @@ -3445,7 +3430,6 @@ waitchld (wpid, block) pid_t pid; int call_set_current, last_stopped_job, job, children_exited, waitpid_flags; - int called_from_sighand = sigchld; static int wcontinued = WCONTINUED; /* run-time fix for glibc problem */ call_set_current = children_exited = 0; diff --git a/jobs.h b/jobs.h index 6df0607..4ba3513 100644 --- a/jobs.h +++ b/jobs.h @@ -190,7 +190,6 @@ extern JOB **jobs; extern void making_children __P((void)); extern void stop_making_children __P((void)); extern void cleanup_the_pipeline __P((void)); -extern void discard_last_procsub_child __P((void)); extern void save_pipeline __P((int)); extern PROCESS *restore_pipeline __P((int)); extern void start_pipeline __P((void)); diff --git a/lib/glob/glob.c b/lib/glob/glob.c index c018e29..7f6eafe 100644 --- a/lib/glob/glob.c +++ b/lib/glob/glob.c @@ -576,7 +576,7 @@ glob_vector (pat, dir, flags) register char *nextname, *npat, *subdir; unsigned int count; int lose, skip, ndirs, isdir, sdlen, add_current, patlen; - register char **name_vector = NULL; + register char **name_vector; register unsigned int i; int mflags; /* Flags passed to strmatch (). */ int pflags; /* flags passed to sh_makepath () */ @@ -894,7 +894,7 @@ glob_vector (pat, dir, flags) } /* Don't call QUIT; here; let higher layers deal with it. */ - FREE (name_vector); + return ((char **)NULL); } diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index 65179e2..c3a2aa3 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -330,12 +330,6 @@ PARSE_COLLSYM (p, vp) for (pc = 0; p[pc]; pc++) if (p[pc] == L('.') && p[pc+1] == L(']')) break; - if (p[pc] == 0) - { - if (vp) - *vp = INVALID; - return (p + pc); - } val = COLLSYM (p, pc); if (vp) *vp = val; @@ -489,9 +483,6 @@ BRACKMATCH (p, test, flags) c = *p++; c = FOLD (c); - if (c == L('\0')) - return ((test == L('[')) ? savep : (CHAR *)0); - if ((flags & FNM_PATHNAME) && c == L('/')) /* [/] can never match when matching a pathname. */ return (CHAR *)0; diff --git a/lib/readline/display.c b/lib/readline/display.c index 2d2e768..41fb053 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -771,9 +771,7 @@ rl_redisplay () appear in the first and last lines of the prompt */ wadjust = (newlines == 0) ? prompt_invis_chars_first_line - : ((newlines == prompt_lines_estimate) - ? (wrap_offset - prompt_invis_chars_first_line) - : 0); + : ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line); /* fix from Darin Johnson for prompt string with invisible characters that is longer than the screen width. The diff --git a/lib/readline/history.c b/lib/readline/history.c index 129c57a..3b8dbc5 100644 --- a/lib/readline/history.c +++ b/lib/readline/history.c @@ -57,8 +57,6 @@ extern int errno; /* How big to make the_history when we first allocate it. */ #define DEFAULT_HISTORY_INITIAL_SIZE 502 -#define MAX_HISTORY_INITIAL_SIZE 8192 - /* The number of slots to increase the_history by. */ #define DEFAULT_HISTORY_GROW_SIZE 50 @@ -279,7 +277,6 @@ add_history (string) const char *string; { HIST_ENTRY *temp; - int new_length; if (history_stifled && (history_length == history_max_entries)) { @@ -296,9 +293,13 @@ add_history (string) /* Copy the rest of the entries, moving down one slot. Copy includes trailing NULL. */ +#if 0 + for (i = 0; i < history_length; i++) + the_history[i] = the_history[i + 1]; +#else memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *)); +#endif - new_length = history_length; history_base++; } else @@ -306,13 +307,11 @@ add_history (string) if (history_size == 0) { if (history_stifled && history_max_entries > 0) - history_size = (history_max_entries > MAX_HISTORY_INITIAL_SIZE) - ? MAX_HISTORY_INITIAL_SIZE - : history_max_entries + 2; + history_size = history_max_entries + 2; else history_size = DEFAULT_HISTORY_INITIAL_SIZE; the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *)); - new_length = 1; + history_length = 1; } else { @@ -322,15 +321,14 @@ add_history (string) the_history = (HIST_ENTRY **) xrealloc (the_history, history_size * sizeof (HIST_ENTRY *)); } - new_length = history_length + 1; + history_length++; } } temp = alloc_history_entry ((char *)string, hist_inittime ()); - the_history[new_length] = (HIST_ENTRY *)NULL; - the_history[new_length - 1] = temp; - history_length = new_length; + the_history[history_length] = (HIST_ENTRY *)NULL; + the_history[history_length - 1] = temp; } /* Change the time stamp of the most recent history entry to STRING. */ diff --git a/lib/readline/readline.c b/lib/readline/readline.c index 17fad28..e51df4f 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -55,12 +55,6 @@ extern int errno; #endif /* !errno */ -#if defined (HAVE_DECL_AUDIT_USER_TTY) -# include -# include -# include -#endif - /* System-specific feature definitions and include files. */ #include "rldefs.h" #include "rlmbutil.h" @@ -341,48 +335,7 @@ rl_set_prompt (prompt) rl_visible_prompt_length = rl_expand_prompt (rl_prompt); return 0; } - -#if defined (HAVE_DECL_AUDIT_USER_TTY) -/* Report STRING to the audit system. */ -static void -audit_tty (char *string) -{ - struct sockaddr_nl addr; - struct msghdr msg; - struct nlmsghdr nlm; - struct iovec iov[2]; - size_t size; - int fd; - - size = strlen (string) + 1; - fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT); - if (fd < 0) - return; - nlm.nlmsg_len = NLMSG_LENGTH (size); - nlm.nlmsg_type = AUDIT_USER_TTY; - nlm.nlmsg_flags = NLM_F_REQUEST; - nlm.nlmsg_seq = 0; - nlm.nlmsg_pid = 0; - iov[0].iov_base = &nlm; - iov[0].iov_len = sizeof (nlm); - iov[1].iov_base = string; - iov[1].iov_len = size; - addr.nl_family = AF_NETLINK; - addr.nl_pad = 0; - addr.nl_pid = 0; - addr.nl_groups = 0; - msg.msg_name = &addr; - msg.msg_namelen = sizeof (addr); - msg.msg_iov = iov; - msg.msg_iovlen = 2; - msg.msg_control = NULL; - msg.msg_controllen = 0; - msg.msg_flags = 0; - (void)sendmsg (fd, &msg, 0); - close (fd); -} -#endif - + /* Read a line of input. Prompt with PROMPT. An empty PROMPT means none. A return value of NULL means that EOF was encountered. */ char * diff --git a/lib/sh/pathcanon.c b/lib/sh/pathcanon.c index 2a565d6..f19bd55 100644 --- a/lib/sh/pathcanon.c +++ b/lib/sh/pathcanon.c @@ -227,7 +227,7 @@ sh_canonpath (path, flags) if (result[2] == '\0') /* short-circuit for bare `//' */ result[1] = '\0'; else - memmove(result, result + 1, strlen(result + 1) + 1); + strcpy (result, result + 1); } return (result); diff --git a/lib/sh/pathphys.c b/lib/sh/pathphys.c index b64c4cd..26016b7 100644 --- a/lib/sh/pathphys.c +++ b/lib/sh/pathphys.c @@ -245,7 +245,7 @@ error: if (result[2] == '\0') /* short-circuit for bare `//' */ result[1] = '\0'; else - memmove(result, result + 1, strlen(result + 1) + 1); + strcpy (result, result + 1); } return (result); diff --git a/lib/sh/zread.c b/lib/sh/zread.c index 496f20b..868f970 100644 --- a/lib/sh/zread.c +++ b/lib/sh/zread.c @@ -37,10 +37,7 @@ extern int errno; # define SEEK_CUR 1 #endif -extern int executing_builtin; - extern void check_signals_and_traps (void); -extern void check_signals (void); extern int signal_is_trapped (int); /* Read LEN bytes from FD into BUF. Retry the read on EINTR. Any other @@ -53,13 +50,21 @@ zread (fd, buf, len) { ssize_t r; +#if 0 +#if defined (HAVE_SIGINTERRUPT) + if (signal_is_trapped (SIGCHLD)) + siginterrupt (SIGCHLD, 1); +#endif +#endif + while ((r = read (fd, buf, len)) < 0 && errno == EINTR) - /* XXX - bash-5.0 */ - /* We check executing_builtin and run traps here for backwards compatibility */ - if (executing_builtin) - check_signals_and_traps (); /* XXX - should it be check_signals()? */ - else - check_signals (); + check_signals_and_traps (); /* XXX - should it be check_signals()? */ + +#if 0 +#if defined (HAVE_SIGINTERRUPT) + siginterrupt (SIGCHLD, 0); +#endif +#endif return r; } diff --git a/locale.c b/locale.c index ffc7b5c..a199cdf 100644 --- a/locale.c +++ b/locale.c @@ -77,6 +77,8 @@ set_default_locale () { #if defined (HAVE_SETLOCALE) default_locale = setlocale (LC_ALL, ""); + if (default_locale) + default_locale = savestring (default_locale); #endif /* HAVE_SETLOCALE */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); diff --git a/make_cmd.c b/make_cmd.c index a982fe0..b42e9ff 100644 --- a/make_cmd.c +++ b/make_cmd.c @@ -42,15 +42,11 @@ #include "flags.h" #include "make_cmd.h" #include "dispose_cmd.h" -#include "execute_cmd.h" #include "variables.h" #include "subst.h" #include "input.h" #include "ocache.h" #include "externs.h" -#include "builtins.h" - -#include "builtins/common.h" #if defined (JOB_CONTROL) #include "jobs.h" @@ -61,10 +57,6 @@ extern int line_number, current_command_line_count, parser_state; extern int last_command_exit_value; extern int shell_initialized; -extern int rpm_requires; - -static char *alphabet_set = "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int here_doc_first_line = 0; @@ -847,27 +839,6 @@ make_coproc_command (name, command) return (make_command (cm_coproc, (SIMPLE_COM *)temp)); } -static void -output_requirement (deptype, filename) -const char *deptype; -char *filename; -{ - if (strchr(filename, '$') || (filename[0] != '/' && strchr(filename, '/'))) - return; - - /* - if the executable is called via variable substitution we can - not dermine what it is at compile time. - - if the executable consists only of characters not in the - alphabet we do not consider it a dependency just an artifact - of shell parsing (ex "exec < ${infile}"). - */ - - if (strpbrk(filename, alphabet_set)) - printf ("%s(%s)\n", deptype, filename); -} - /* Reverse the word list and redirection list in the simple command has just been parsed. It seems simpler to do this here the one time then by any other method that I can think of. */ @@ -885,27 +856,6 @@ clean_simple_command (command) REVERSE_LIST (command->value.Simple->redirects, REDIRECT *); } - if (rpm_requires && command->value.Simple->words) - { - char *cmd0; - char *cmd1; - struct builtin *b; - - cmd0 = command->value.Simple->words->word->word; - b = builtin_address_internal (cmd0, 0); - cmd1 = 0; - if (command->value.Simple->words->next) - cmd1 = command->value.Simple->words->next->word->word; - - if (b) { - if ( (b->flags & REQUIRES_BUILTIN) && cmd1) - output_requirement ("executable", cmd1); - } else { - if (!assignment(cmd0, 0)) - output_requirement (find_function(cmd0) ? "function" : "executable", cmd0); - } - } /*rpm_requires*/ - parser_state &= ~PST_REDIRLIST; return (command); } diff --git a/parse.y b/parse.y index 2a98372..f415d2e 100644 --- a/parse.y +++ b/parse.y @@ -1426,7 +1426,7 @@ input_file_descriptor () #if defined (READLINE) char *current_readline_prompt = (char *)NULL; -unsigned char *current_readline_line = (unsigned char *)NULL; +char *current_readline_line = (char *)NULL; int current_readline_line_index = 0; static int @@ -1453,7 +1453,6 @@ yy_readline_get () old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler); } - sh_unset_nodelay_mode (fileno (rl_instream)); /* just in case */ current_readline_line = readline (current_readline_prompt ? current_readline_prompt : ""); @@ -4011,13 +4010,11 @@ eof_error: tflags |= LEX_RESWDOK; lex_rwlen = 0; } - else if (shellmeta (ch) == 0) + else { tflags &= ~LEX_RESWDOK; /*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 0", line_number, ret+retind-4);*/ } - else /* can't be in a reserved word any more */ - lex_rwlen = 0; } else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0))) ; /* don't modify LEX_RESWDOK if we're starting a comment */ @@ -4193,7 +4190,7 @@ eof_error: FREE (nestret); } - if MBTEST(ch == '$' && (tflags & LEX_WASDOL) == 0) + if MBTEST(ch == '$') tflags |= LEX_WASDOL; else tflags &= ~LEX_WASDOL; @@ -4231,8 +4228,6 @@ xparse_dolparen (base, string, indp, flags) save_parser_state (&ps); save_input_line_state (&ls); orig_eof_token = shell_eof_token; - /* avoid echoing every substitution again */ - echo_input_at_read = 0; /*(*/ parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/ diff --git a/patchlevel.h b/patchlevel.h index a711c49..1cd7c96 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 19 +#define PATCHLEVEL 0 #endif /* _PATCHLEVEL_H_ */ diff --git a/redir.c b/redir.c index 1858b0b..25488ea 100644 --- a/redir.c +++ b/redir.c @@ -469,8 +469,6 @@ here_document_to_fd (redirectee, ri) return (fd); } - SET_CLOSE_ON_EXEC (fd); - errno = r = 0; /* XXX */ /* write_here_document returns 0 on success, errno on failure. */ if (redirectee->word) diff --git a/shell.c b/shell.c index 4aae182..45b77f9 100644 --- a/shell.c +++ b/shell.c @@ -201,9 +201,6 @@ int have_devfd = 0; /* The name of the .(shell)rc file. */ static char *bashrc_file = DEFAULT_BASHRC; -/* Non-zero if we are finding the scripts requirements. */ -int rpm_requires; - /* Non-zero means to act more like the Bourne shell on startup. */ static int act_like_sh; @@ -267,7 +264,6 @@ static const struct { { "protected", Int, &protected_mode, (char **)0x0 }, #endif { "rcfile", Charp, (int *)0x0, &bashrc_file }, - { "rpm-requires", Int, &rpm_requires, (char **)0x0 }, #if defined (RESTRICTED_SHELL) { "restricted", Int, &restricted, (char **)0x0 }, #endif @@ -504,12 +500,6 @@ main (argc, argv, env) if (dump_translatable_strings) read_but_dont_execute = 1; - if (rpm_requires) - { - read_but_dont_execute = 1; - initialize_shell_builtins (); - } - if (running_setuid && privileged_mode == 0) disable_priv_mode (); @@ -1948,10 +1938,8 @@ show_shell_usage (fp, extra) fputs (_("\t-ilrsD or -c command or -O shopt_option\t\t(invocation only)\n"), fp); for (i = 0, set_opts = 0; shell_builtins[i].name; i++) - if (STREQ (shell_builtins[i].name, "set")) { + if (STREQ (shell_builtins[i].name, "set")) set_opts = savestring (shell_builtins[i].short_doc); - break; - } if (set_opts) { s = strchr (set_opts, '['); diff --git a/sig.c b/sig.c index e5bb739..ad01631 100644 --- a/sig.c +++ b/sig.c @@ -585,8 +585,7 @@ termsig_handler (sig) #if defined (JOB_CONTROL) if (sig == SIGHUP && (interactive || (subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB)))) hangup_all_jobs (); - if ((subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB)) == 0) - end_job_control (); + end_job_control (); #endif /* JOB_CONTROL */ #if defined (PROCESS_SUBSTITUTION) diff --git a/subst.c b/subst.c index 7574617..f1a4df1 100644 --- a/subst.c +++ b/subst.c @@ -2825,15 +2825,11 @@ list_string (string, separators, quoted) /* Parse a single word from STRING, using SEPARATORS to separate fields. ENDPTR is set to the first character after the word. This is used by - the `read' builtin. - - This is never called with SEPARATORS != $IFS, and takes advantage of that. + the `read' builtin. This is never called with SEPARATORS != $IFS; + it should be simplified. XXX - this function is very similar to list_string; they should be combined - XXX */ - -#define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0) - char * get_word_from_string (stringp, separators, endptr) char **stringp, *separators, **endptr; @@ -2841,7 +2837,6 @@ get_word_from_string (stringp, separators, endptr) register char *s; char *current_word; int sindex, sh_style_split, whitesep, xflags; - unsigned char local_cmap[UCHAR_MAX+1]; /* really only need single-byte chars here */ size_t slen; if (!stringp || !*stringp || !**stringp) @@ -2851,23 +2846,20 @@ get_word_from_string (stringp, separators, endptr) separators[1] == '\t' && separators[2] == '\n' && separators[3] == '\0'; - memset (local_cmap, '\0', sizeof (local_cmap)); - for (xflags = 0, s = separators; s && *s; s++) + for (xflags = 0, s = ifs_value; s && *s; s++) { if (*s == CTLESC) xflags |= SX_NOCTLESC; if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL; - local_cmap[(unsigned char)*s] = 1; /* local charmap of separators */ } s = *stringp; slen = 0; /* Remove sequences of whitespace at the beginning of STRING, as - long as those characters appear in SEPARATORS. This happens if - SEPARATORS == $' \t\n' or if IFS is unset. */ - if (sh_style_split || separators == 0) + long as those characters appear in IFS. */ + if (sh_style_split || !separators || !*separators) { - for (; *s && spctabnl (*s) && islocalsep (*s); s++); + for (; *s && spctabnl (*s) && isifs (*s); s++); /* If the string is nothing but whitespace, update it and return. */ if (!*s) @@ -2886,9 +2878,9 @@ get_word_from_string (stringp, separators, endptr) This obeys the field splitting rules in Posix.2. */ sindex = 0; - /* Don't need string length in ADVANCE_CHAR unless multibyte chars are - possible, but need it in string_extract_verbatim for bounds checking */ - slen = STRLEN (s); + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1; current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags); /* Set ENDPTR to the first character after the end of the word. */ @@ -2907,19 +2899,19 @@ get_word_from_string (stringp, separators, endptr) /* Now skip sequences of space, tab, or newline characters if they are in the list of separators. */ - while (s[sindex] && spctabnl (s[sindex]) && islocalsep (s[sindex])) + while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex])) sindex++; /* If the first separator was IFS whitespace and the current character is a non-whitespace IFS character, it should be part of the current field delimiter, not a separate delimiter that would result in an empty field. Look at POSIX.2, 3.6.5, (3)(b). */ - if (s[sindex] && whitesep && islocalsep (s[sindex]) && !spctabnl (s[sindex])) + if (s[sindex] && whitesep && isifs (s[sindex]) && !spctabnl (s[sindex])) { sindex++; /* An IFS character that is not IFS white space, along with any adjacent IFS white space, shall delimit a field. */ - while (s[sindex] && spctabnl (s[sindex]) && islocalsep(s[sindex])) + while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex])) sindex++; } @@ -5182,11 +5174,8 @@ parameter_list_transform (xc, itype, quoted) list = list_rest_of_args (); if (list == 0) return ((char *)NULL); - if (xc == 'A') { - ret = pos_params_assignment (list, itype, quoted); - dispose_words (list); - return (ret); - } + if (xc == 'A') + return (pos_params_assignment (list, itype, quoted)); ret = list_transform (xc, (SHELL_VAR *)0, list, itype, quoted); dispose_words (list); return (ret); @@ -5819,7 +5808,10 @@ process_substitute (string, open_for_read_in_child) { #if defined (JOB_CONTROL) if (last_procsub_child) - discard_last_procsub_child (); + { + discard_pipeline (last_procsub_child); + last_procsub_child = (PROCESS *)NULL; + } last_procsub_child = restore_pipeline (0); #endif @@ -5909,8 +5901,6 @@ process_substitute (string, open_for_read_in_child) parent. */ expanding_redir = 0; - remove_quoted_escapes (string); - subshell_level++; result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST)); subshell_level--; @@ -5941,7 +5931,6 @@ read_comsub (fd, quoted, rflag) char *istring, buf[128], *bufp, *s; int istring_index, istring_size, c, tflag, skip_ctlesc, skip_ctlnul; ssize_t bufn; - int nullbyte; istring = (char *)NULL; istring_index = istring_size = bufn = tflag = 0; @@ -5949,8 +5938,6 @@ read_comsub (fd, quoted, rflag) for (skip_ctlesc = skip_ctlnul = 0, s = ifs_value; s && *s; s++) skip_ctlesc |= *s == CTLESC, skip_ctlnul |= *s == CTLNUL; - nullbyte = 0; - /* Read the output of the command through the pipe. This may need to be changed to understand multibyte characters in the future. */ while (1) @@ -5969,11 +5956,7 @@ read_comsub (fd, quoted, rflag) if (c == 0) { #if 1 - if (nullbyte == 0) - { - internal_warning ("%s", _("command substitution: ignored null byte in input")); - nullbyte = 1; - } + internal_warning ("%s", _("command substitution: ignored null byte in input")); #endif continue; } @@ -6816,7 +6799,6 @@ parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdolla { report_error (_("%s: invalid indirect expansion"), name); free (vname); - free (t1); dispose_word (w); return &expand_wdesc_error; } @@ -6824,7 +6806,6 @@ parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdolla { report_error (_("%s: invalid variable name"), vname); free (vname); - free (t1); dispose_word (w); return &expand_wdesc_error; } @@ -8532,7 +8513,6 @@ param_expand (string, sindex, quoted, expanded_something, WORD_LIST *list; WORD_DESC *tdesc, *ret; int tflag; - int old_echo_input; /*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/ zindex = *sindex; @@ -8851,9 +8831,6 @@ arithsub: } comsub: - old_echo_input = echo_input_at_read; - /* avoid echoing every substitution again */ - echo_input_at_read = 0; if (pflags & PF_NOCOMSUB) /* we need zindex+1 because string[zindex] == RPAREN */ temp1 = substring (string, *sindex, zindex+1); @@ -8866,7 +8843,6 @@ comsub: } FREE (temp); temp = temp1; - echo_input_at_read = old_echo_input; break; /* Do POSIX.2d9-style arithmetic substitution. This will probably go @@ -9478,10 +9454,6 @@ add_twochars: tword->flags |= word->flags & (W_ASSIGNARG|W_ASSIGNRHS); /* affects $@ */ if (word->flags & W_COMPLETE) tword->flags |= W_COMPLETE; /* for command substitutions */ - if (word->flags & W_NOCOMSUB) - tword->flags |= W_NOCOMSUB; - if (word->flags & W_NOPROCSUB) - tword->flags |= W_NOPROCSUB; temp = (char *)NULL; @@ -10683,12 +10655,11 @@ expand_word_list_internal (list, eflags) tint = do_word_assignment (temp_list->word, 0); this_command_name = savecmd; /* Variable assignment errors in non-interactive shells - running in Posix.2 mode cause the shell to exit, unless - they are being run by the `command' builtin. */ + running in Posix.2 mode cause the shell to exit. */ if (tint == 0) { last_command_exit_value = EXECUTION_FAILURE; - if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0) + if (interactive_shell == 0 && posixly_correct) exp_jump_to_top_level (FORCE_EOF); else exp_jump_to_top_level (DISCARD); diff --git a/support/man2html.c b/support/man2html.c index 1d9e376..6ba5061 100644 --- a/support/man2html.c +++ b/support/man2html.c @@ -522,7 +522,6 @@ read_man_page(char *filename) man_buf[buf_size] = '\n'; man_buf[buf_size + 1] = man_buf[buf_size + 2] = '\0'; } else { - free (man_buf); man_buf = NULL; } fclose(man_stream); @@ -2563,6 +2562,7 @@ scan_request(char *c) h = name; if (stat(h, &stbuf) != -1) l = stbuf.st_size; + buf = stralloc(l + 4); #if NOCGI if (!out_length) { char *t, *s; diff --git a/tests/exec.right b/tests/exec.right index ff77f09..81224fa 100644 --- a/tests/exec.right +++ b/tests/exec.right @@ -51,6 +51,7 @@ this is ohio-state 0 1 testb +expand_aliases on 1 1 1 diff --git a/tests/execscript b/tests/execscript index 75c48a4..3415ae3 100644 --- a/tests/execscript +++ b/tests/execscript @@ -108,6 +108,8 @@ ${THIS_SH} ./exec6.sub # checks for properly deciding what constitutes an executable file ${THIS_SH} ./exec7.sub +${THIS_SH} -i ./exec8.sub + ${THIS_SH} ./exec9.sub ${THIS_SH} ./exec10.sub diff --git a/tests/read.right b/tests/read.right index a92fe7f..73cb704 100644 --- a/tests/read.right +++ b/tests/read.right @@ -33,6 +33,14 @@ a = abcdefg a = xyz a = -xyz 123- a = abc +timeout 1: ok + +timeout 2: ok + +./read2.sub: line 23: read: -3: invalid timeout specification +1 + +abcde ./read3.sub: line 4: read: -1: invalid number abc ab diff --git a/tests/read.tests b/tests/read.tests index 10346f7..fe27dae 100644 --- a/tests/read.tests +++ b/tests/read.tests @@ -82,6 +82,9 @@ echo " foo" | { IFS=$':' ; read line; recho "$line"; } # test read -d delim behavior ${THIS_SH} ./read1.sub +# test read -t timeout behavior +${THIS_SH} ./read2.sub + # test read -n nchars behavior ${THIS_SH} ./read3.sub diff --git a/variables.h b/variables.h index be3aebc..25c9ae0 100644 --- a/variables.h +++ b/variables.h @@ -95,8 +95,8 @@ typedef struct variable { typedef struct _vlist { SHELL_VAR **list; - size_t list_size; /* allocated size */ - size_t list_len; /* current number of entries */ + int list_size; /* allocated size */ + int list_len; /* current number of entries */ } VARLIST; /* The various attributes that a given variable can have. */