sh: Sync with FreeBSD
authorPeter Avalos <pavalos@dragonflybsd.org>
Mon, 7 Feb 2011 08:05:28 +0000 (22:05 -1000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sat, 12 Feb 2011 07:08:36 +0000 (21:08 -1000)
commit99512ac4b46c423d7a70b99c3d0c20769afaf083
tree081b6f27c7847467c9876a8ebbea6d4346daf1a5
parentb44f1d28e32da8224aa0e940bae5002be94c91fc
sh: Sync with FreeBSD

This is a combination of 198 commits that enhances performance,
standards compliance, and bug fixes:

-Fix exit status of case statement.
-sh.1: Update markup.
-Fix PWD values.
-Fix null pointer dereferences.
-Fix bugs where arithmetic expansion$((...)) was truncated
-Pass the correct flags to expandarg() for NFROMFD and NTOFD.
-Add __dead2
-Fix $? at the first command of a function.
-Report error messages to stderr instead of stdout.
-Make alias builtin POSIX compliant.
-Improve the IFS handling of the read built-in.
-Don't let empty lines overwrite the result of the last command with 0.
-Fix the eval command in combination with set -e.
-Make read's timeout (-t) apply to the entire line.
-align local ckmalloc() with malloc(3) by using a size_t
-style(9) to enhance readability
-explicit 'unsigned int' instead of just 'unsigned'
-Mention the range for the exit status for the exit builtin
-Don't skip forking for an external command if any traps are active.
-Avoid leaving unnecessary waiting shells.
-Properly flush input after an error in backquotes
-Fix some issues with quoted output
-Fix race condition in noclobber option
-Improve handling of setjmp/longjmp volatile
-Do not fork for EV_EXIT.
-Quote -x tracing output so it is unambiguous.
-Designate special builtins as such in command -V and type.
-Fix crash when undefining or redefining an executing function.
-Fix memory leak when using a variable in arithmetic like $((x)).
-Use sigaction instead of signal/siginterrupt combination.
-Allow a newline before "in" in a for command, as required by POSIX.
-Some changes to stderr flushing.
-Handle current work directories of arbitrary length.
-trap: do not consider a bad signal name a fatal error.
-Ensure the same command input file is on top after execing builtin.
-Fix various things about SIGINT handling.
-Fix some cases where file descriptors from redirections leak to programs.
-Remove setting variables from dotcmd/exportcmd.
-Fix a memory leak when calling . with variable assignments.
-Constify various strings.
-Do not consider a tilde-prefix with expansions in it.
-Do not run callers' exception handlers in subshells.
-Remove declaration of function that no longer exists.
-WARNS fixes to reduce diffs to FreeBSD
-arith: Return only 0 and 1 from && and ||.
-Fix memory leak when parsing backticks (``).
-Ensure funcnest is decremented if there's an error in the function.
-Allow command -pv and command -pV
-Fix some bugs with backquoted builtins.
-Send the "not found" message for builtin <cmd> to redirected fd 2.
-Do not stat() $MAIL/$MAILPATH in non-interactive shells.
-Fix expansion of \W in prompt strings when the working directory is "/".
-Improve the command builtin:
-Make sure to popredir() even if a special builtin caused an error.
-Make sure to popredir() even if a function caused an error.
-Make parsebackq a function instead of an emulated nested function.
-Do not abort on a redirection error if there is no command word.
-Do not abort on a redirection error on a compound command.
-Treat unexpected newlines in substitutions as a syntax error.
-Fix various things about expansions.
-Remove special handling for ' and " in arithmetic.
-Allow quoting pattern match characters in ${v%pat} and ${v#pat}.
-Do tilde expansion in substitutions.
-Automatically enable -o emacs in interactive shells with terminals.
-On startup of the shell, use PWD from the environment if it is valid.
-Use stalloc for arith variable names.
-Apply locale vars on builtins, recognize LC_MESSAGES as a locale var.
-Have only one copy of _PATH_STDPATH in the binary.
-Fix "reserved word" vs "keyword" inconsistency.
-Fix pathname expansion with quoted slashes like *\/.
-Reap any zombies before forking for a background command.
-Rework documentation of shell variables.
-Recognize "--" in . and exec.
-Change interaction of command substitution and here documents.
-Fix a crash if a heredoc was not properly ended and parsing continued.
-Pass TERM changes to libedit.
-Pass through SIGINT from a child if interactive and job control is enabled.
-Forget about terminated background processes sooner.
-Use $PWD instead of getcwd() for the \w and \W prompt expansions.
-Allow a background command consisting solely of redirections.
-Fix crash due to uninitialized here-document.
-Return 0 from eval if no command was given.
-Remove unnecessary duplicate letters in mksyntax.c
-Fix heap-based buffer overflow in pathname generation.
-Fix shadowing of sigset.
-Fix break/continue/return sometimes not skipping the rest of dot script.
-Add a brief summary of arithmetic expressions.
-Remove remnants of '!!' to negate pattern.
-Do not use locale for determining if something is a name.
-Get rid of some magic numbers.
-Improve comments in expand.c.
-Fix 'read' if all chars before the first IFS char are backslash-escaped.
-Remove xrefs for expr(1) and getopt(1).
-Apply variable assignments left-to-right in bltinlookup().
-Fix exit status if return is used within a loop condition.
-Suggest that DEBUG_FLAGS be used to enable extra debugging
-Make DEBUG traces 64-bit clean.
-Remove the "STATIC" macro
-Fix a bug in STACKSTRNUL()
-Clarify subshells/processes for pipelines.
-There cannot be a TNOT in simplecmd(), remove checks.
-Change ! within a pipeline to start a new pipeline instead.
-Check whether dup2 was successful for >&FD and <&FD.
-Make sure defined functions can actually be called.
-Do not allow overriding a special builtin with a function.
-Ignore double-quotes in arithmetic rather than treating them as quotes.
-Make double-quotes quote a '}' inside ${v#...} and ${v%...}.
-Only accept a '}' inside ${v+-=?...} if double-quote state matches.
-Do IFS splitting on word in ${v+word} and ${v-word}.
-Fix some issues with CTL* bytes and ${var#pat}.
-Error out on various specials/keywords in the wrong place in backticks.
-Detect various additional errors in the parser.
-Reject function names ending in one of !%*+-=?@}~
-Tweak some string constants to reduce code size.
-Use iteration instead of recursion to evaluate semicolon lists.
-Reindent evaltree().
-Correct synopsis and make precise how $0 is set.
-Fix some issues with aliases and case, by importing dash checkkwd code.
-Modernize the introduction a bit.
-Remove unused man page for echo builtin.
-Do the additional actions if 'local -' restore changes -i/-m/-E/-V.
-Add binary buffered output for use by the printf builtin.
-document printf builtin
-Code size optimizations to buffered output.
-Remove the check that alpha/name/in_name chars are not CTL* bytes.
-Fix confusing behaviour if chdir succeeded but getcwd failed in cd -P.
-Code size optimizations to "stack string" memory allocation
-jobs -p: Do not ask the kernel for the pgid.
-Improve jobs output of pipelines.
-POSIX says there should not be a space between Done and (exitstatus).
-Improve internal-representation-to-text code to avoid binary output.
-Use vsnprintf() rather than crafting our own in fmtstr().
-Replace some macros and repeated code in expand.c with functions.
-Remove the herefd hack.
-Various simplifications to jobs.c
-Remove duplicate check, turning dead code into live code.
-Fix corruption of command substitutions with special chars after newline
-Remove dead code.
-arith: Disallow decimal constants starting with 0 (containing 8 or 9).
-Make warnings in the printf builtin non-fatal.
-Add a function to print warnings (with command name and newline).
-Add kill builtin.
-Explain why it is a bad idea to use aliases in scripts.
-Allow arbitrary large numbers in CHECKSTRSPACE.
-Make expansion errors in optimized command substitution non-fatal.
-Don't do optimized command substitution if expansions have side effects.
-Properly restore exception handler in fc.
-Avoid side effects from builtins in optimized command substitution.
-Check if dup2 for redirection from/to a file succeeds.
-Check readonly status for assignments on regular builtins.
-Do not call exitshell() from evalcommand() unless evalcommand() forked itself
-Make exit without parameters from EXIT trap POSIX-compliant.
-Remove special %builtin PATH entry.
-Make 'trap -l' look like 'kill -l'.
-Fix some things about -- in trap.
-If exit is used without args from a trap action, exit on the signal.
-Fix signal messages being sent to the wrong file sometimes.
-Send messages about signals to stderr.
-Return only 126 or 127 for execve() failures.
-Make sys_signame upper case.
-Remove special code for shell scripts without magic number.
-Do not try to execute binary files as scripts.
-Forget all cached command locations on any PATH change.
-Fix two things about {(...)} <redir.
-Import arithmetic expression code from dash.
-Install /bin/sh safely.

Obtained-from: FreeBSD
74 files changed:
bin/kill/kill.1
bin/kill/kill.c
bin/sh/Makefile
bin/sh/TOUR
bin/sh/alias.c
bin/sh/alias.h
bin/sh/arith.h
bin/sh/arith.y [deleted file]
bin/sh/arith_lex.l [deleted file]
bin/sh/arith_yacc.c [new file with mode: 0644]
bin/sh/arith_yacc.h [copied from bin/sh/alias.h with 56% similarity]
bin/sh/arith_yylex.c [new file with mode: 0644]
bin/sh/bltin/bltin.h
bin/sh/bltin/echo.1 [deleted file]
bin/sh/bltin/echo.c
bin/sh/builtins.def
bin/sh/cd.c
bin/sh/cd.h
bin/sh/error.c
bin/sh/error.h
bin/sh/eval.c
bin/sh/eval.h
bin/sh/exec.c
bin/sh/exec.h
bin/sh/expand.c
bin/sh/expand.h
bin/sh/funcs/cmv
bin/sh/funcs/dirs
bin/sh/funcs/kill
bin/sh/funcs/login
bin/sh/funcs/newgrp
bin/sh/funcs/popd
bin/sh/funcs/pushd
bin/sh/funcs/suspend
bin/sh/histedit.c
bin/sh/init.h
bin/sh/input.c
bin/sh/input.h
bin/sh/jobs.c
bin/sh/jobs.h
bin/sh/mail.c
bin/sh/mail.h
bin/sh/main.c
bin/sh/main.h
bin/sh/memalloc.c
bin/sh/memalloc.h
bin/sh/miscbltin.c
bin/sh/mkbuiltins
bin/sh/mkinit.c
bin/sh/mknodes.c
bin/sh/mksyntax.c
bin/sh/mktokens
bin/sh/myhistedit.h
bin/sh/mystring.c
bin/sh/mystring.h
bin/sh/nodes.c.pat
bin/sh/nodetypes
bin/sh/options.c
bin/sh/options.h
bin/sh/output.c
bin/sh/output.h
bin/sh/parser.c
bin/sh/parser.h
bin/sh/redir.c
bin/sh/sh.1
bin/sh/shell.h
bin/sh/show.c
bin/sh/show.h
bin/sh/trap.c
bin/sh/trap.h
bin/sh/var.c
bin/sh/var.h
bin/test/test.c
usr.bin/printf/printf.c