git: sh: Sync with FreeBSD

看板DFBSD_commit作者時間15年前 (2011/02/12 15:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
commit 99512ac4b46c423d7a70b99c3d0c20769afaf083 Author: Peter Avalos <pavalos@dragonflybsd.org> Date: Sun Feb 6 22:05:28 2011 -1000 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 Summary of changes: bin/kill/kill.1 | 1 + bin/kill/kill.c | 47 ++- bin/sh/Makefile | 27 +- bin/sh/TOUR | 22 +- bin/sh/alias.c | 106 +++-- bin/sh/alias.h | 6 +- bin/sh/arith.h | 13 +- bin/sh/arith.y | 358 ---------------- bin/sh/arith_lex.l | 135 ------- bin/sh/arith_yacc.c | 388 ++++++++++++++++++ bin/sh/arith_yacc.h | 91 +++++ bin/sh/arith_yylex.c | 242 +++++++++++ bin/sh/bltin/bltin.h | 27 +- bin/sh/bltin/echo.1 | 119 ------ bin/sh/bltin/echo.c | 3 +- bin/sh/builtins.def | 4 +- bin/sh/cd.c | 177 +++++---- bin/sh/cd.h | 5 +- bin/sh/error.c | 54 ++- bin/sh/error.h | 15 +- bin/sh/eval.c | 612 ++++++++++++++++++---------- bin/sh/eval.h | 11 +- bin/sh/exec.c | 276 +++++-------- bin/sh/exec.h | 29 +- bin/sh/expand.c | 661 ++++++++++++++++++------------- bin/sh/expand.h | 10 +- bin/sh/funcs/cmv | 6 +- bin/sh/funcs/dirs | 6 +- bin/sh/funcs/kill | 6 +- bin/sh/funcs/login | 6 +- bin/sh/funcs/newgrp | 6 +- bin/sh/funcs/popd | 6 +- bin/sh/funcs/pushd | 6 +- bin/sh/funcs/suspend | 6 +- bin/sh/histedit.c | 61 ++-- bin/sh/init.h | 8 +- bin/sh/input.c | 68 +++- bin/sh/input.h | 8 +- bin/sh/jobs.c | 403 ++++++++++++------- bin/sh/jobs.h | 8 +- bin/sh/mail.c | 9 +- bin/sh/mail.h | 5 +- bin/sh/main.c | 79 ++--- bin/sh/main.h | 6 +- bin/sh/memalloc.c | 79 ++-- bin/sh/memalloc.h | 44 ++- bin/sh/miscbltin.c | 107 ++++-- bin/sh/mkbuiltins | 3 +- bin/sh/mkinit.c | 31 +- bin/sh/mknodes.c | 12 +- bin/sh/mksyntax.c | 29 +- bin/sh/mktokens | 6 +- bin/sh/myhistedit.h | 6 +- bin/sh/mystring.c | 3 +- bin/sh/mystring.h | 3 +- bin/sh/nodes.c.pat | 77 +++-- bin/sh/nodetypes | 5 +- bin/sh/options.c | 65 ++-- bin/sh/options.h | 5 +- bin/sh/output.c | 85 ++-- bin/sh/output.h | 22 +- bin/sh/parser.c | 980 ++++++++++++++++++++++++++------------------- bin/sh/parser.h | 7 +- bin/sh/redir.c | 88 +++-- bin/sh/sh.1 | 1028 +++++++++++++++++++++++++++++------------------ bin/sh/shell.h | 21 +- bin/sh/show.c | 7 +- bin/sh/show.h | 5 +- bin/sh/trap.c | 131 ++++--- bin/sh/trap.h | 7 +- bin/sh/var.c | 265 +++++++------ bin/sh/var.h | 11 +- bin/test/test.c | 1 + usr.bin/printf/printf.c | 30 +- 74 files changed, 4199 insertions(+), 3106 deletions(-) delete mode 100644 bin/sh/arith.y delete mode 100644 bin/sh/arith_lex.l create mode 100644 bin/sh/arith_yacc.c create mode 100644 bin/sh/arith_yacc.h create mode 100644 bin/sh/arith_yylex.c delete mode 100644 bin/sh/bltin/echo.1 http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/99512ac4b46c423d7a70b99c3d0c20769afaf083 -- DragonFly BSD source repository
文章代碼(AID): #1DLZTtIK (DFBSD_commit)