summaryrefslogtreecommitdiffstats
path: root/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* Add prototypes, ANSIfy functions definitions to reduce WARNS=6 output.charnier2012-01-255-5/+6
|
* sh: Fix $? in the first command of a 'for'.jilles2012-01-221-1/+4
| | | | | | In the first command of a 'for', $? should be the exit status of the last pipeline (command substitution in the word list or command before 'for'), not always 0.
* sh: Remove "kill" example function, which is superseded by the kill builtinjilles2012-01-211-49/+0
| | | | MFC after: 1 week
* sh: Fix execution of multiple statements in a trap when evalskip is setdumbbell2012-01-163-2/+34
| | | | | | | | | | | Before this fix, only the first statement of the trap was executed if evalskip was set. This is for example the case when: o "-e" is set for this shell o a trap is set on EXIT o a function returns 1 and causes the script to abort Reviewed by: jilles MFC after: 2 weeks
* sh: Fix some bugs with exit status from case containing ;&.jilles2012-01-151-9/+24
| | | | | | | | | | | | | Also, rework evalcase() to not evaluate any tree. Instead, return the NCLISTFALLTHRU node and handle it in evaltree(). Fixed bugs: * If a ;& list with non-zero exit status is followed by an empty ;; or final list, the exit status of the case command should be equal to the exit status of the ;& list, not 0. * An empty ;& case should not reset $?.
* sh: Fix two bugs with case and exit status:jilles2012-01-151-1/+3
| | | | | | | * If no pattern is matched, POSIX says the exit status shall be 0 (even if there are command substitutions). * If a pattern is matched and there are no command substitutions, the first command should see the $? from before the case command, not always 0.
* sh: Change input buffer size from 1023 to 1024.jilles2012-01-141-6/+6
| | | | PR: bin/161756
* sh: Fix out of bounds array access when trap is used with an invalid signal.jilles2012-01-141-2/+2
| | | | MFC after: 1 week
* sh: Properly show "Not a directory" error in cd builtin.jilles2012-01-131-1/+6
| | | | | | | | The errno message display added in r222292 did not take attempting to cd to a non-directory or something that cannot be stat()ed into account. PR: bin/164070 MFC after: 10 days
* sh: Make various functions static.jilles2012-01-0110-12/+12
|
* sh: Remove unused function scopyn().jilles2012-01-012-20/+0
|
* sh: Make patmatch() non-recursive.jilles2012-01-011-37/+58
|
* sh: Allow quoting ^ and ] in bracket expressions.jilles2011-12-281-4/+4
|
* sh: Use dirent.d_type in pathname generation.jilles2011-12-281-0/+4
| | | | | | This improves performance for globs where a slash or another component follows a component with metacharacters by eliminating unnecessary attempts to open directories that are not.
* sh: Cache de->d_namlen in a local variable.jilles2011-12-281-6/+8
|
* sh: Do not force special builtins non-special in optimized command subst.jilles2011-12-281-2/+1
| | | | | | | | | This is not necessary: errors are already caught in evalbackcmd() and forcelocal handles changes to variables. Note that this depends on r223024. MFC after: 4 weeks
* sh: Remove impossible evalskip check in 'for'.jilles2011-11-271-3/+0
|
* sh: Reduce one level of evaltree() recursion when executing 'case'.jilles2011-11-261-11/+9
| | | | | | | Free expanded case text before executing commands. Remove impossible evalskip checks (expanding an argument cannot set evalskip anymore since $(break) and the like are properly executed in a subshell environment).
* sh: Allow unsetting OPTIND.jilles2011-11-201-2/+3
| | | | Note that only assigning the decimal value 1 resets getopts, as before.
* sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic.jilles2011-11-081-3/+3
| | | | With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged.
* sh(1): Improve documentation of field splitting.jilles2011-11-051-11/+55
|
* sh(1): Extend documentation about subshells.jilles2011-07-101-8/+46
| | | | | | | | | | | Because sh executes commands in subshell environments without forking in more and more cases (particularly from 8.0 on), it makes sense to describe subshell environments more precisely using ideas from POSIX, together with some FreeBSD-specific items. In particular, the hash and times builtins may not behave as if their state is copied for a subshell environment while leaving the parent shell environment unchanged.
* sh: Include <limits.h> instead of non-standard <sys/limits.h>.jilles2011-06-261-1/+1
|
* sh(1): Improve documentation of shell patterns:jilles2011-06-241-5/+10
| | | | | | | | | | | * Shell patterns are also for ${var#pat} and the like. * An '!' by itself will not trigger pathname generation so do not call it a meta-character, even though it has a special meaning directly after an '['. * Character ranges are locale-dependent. * A '^' will complement a character class like '!' but is non-standard. MFC after: 1 week
* sh(1): Document the case command better.jilles2011-06-241-2/+13
| | | | | Suggested by: netchild Reviewed by: gjb
* Remove duplicated header fileskevlo2011-06-241-1/+0
|
* sh: Remove special support for background simple commands.jilles2011-06-183-9/+5
| | | | It expands the arguments in the parent shell process, which is incorrect.
* sh: Add do-nothing -h option.jilles2011-06-182-2/+8
| | | | | | | | | | POSIX requires a -h option to sh and set, to locate and remember utilities invoked by functions as they are defined. Given that this locate-and-remember process is optional elsewhere, it seems safe enough to make this option do nothing. POSIX does not specify a long name for this option. Follow ksh in calling it "trackall".
* sh: Add case statement fallthrough (with ';&' instead of ';;').jilles2011-06-175-7/+28
| | | | | | | | | | | | Replacing ;; with the new control operator ;& will cause the next list to be executed as well without checking its pattern, continuing until a list ends with ;; or until the end of the case statement. This is like omitting "break" in a C "switch" statement. The sequence ;& was formerly invalid. This feature is proposed for the next POSIX issue in Austin Group issue #449.
* sh: Skip variables with invalid names in "set", "export -p", "readonly -p".jilles2011-06-171-0/+13
| | | | This ensures the output of these commands is valid shell input.
* sh: Reduce unnecessary forks with eval.jilles2011-06-161-1/+2
| | | | | | | | | | The eval special builtin now runs the code with EV_EXIT if it was run with EV_EXIT itself. In particular, this eliminates one fork when a command substitution contains an eval command that ends with an external program or a subshell. This is similar to what r220978 did for functions.
* sh: Add support for named character classes in bracket expressions.jilles2011-06-152-2/+48
| | | | | Example: case x in [[:alpha:]]) echo yes ;; esac
* sh: Fix duplicate prototypes for builtins.jilles2011-06-1323-41/+14
| | | | | | Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers.
* sh: Save/restore changed variables in optimized command substitution.jilles2011-06-127-89/+25
| | | | | | | | | | | In optimized command substitution, save and restore any variables changed by expansions (${var=value} and $((var=assigned))), instead of trying to determine if an expansion may cause such changes. If $! is referenced in optimized command substitution, do not cause jobs to be remembered longer. This fixes $(jobs $!) again, simplifies the man page and shortens the code.
* sh: Fix locale-dependent ranges in bracket expressions.jilles2011-06-121-4/+4
| | | | | | | | When I added UTF-8 support in r221646, the LC_COLLATE-based ordering broke because of sign extension of char. Because of libc restrictions, this does not work for UTF-8. For UTF-8 locales, ranges always use character code order.
* sh: Read .profile from the home directory (or / if HOME is not set).jilles2011-06-121-1/+1
| | | | | | | | | | In most cases, login shells are started from the home directory, but not in all, such as xterm -ls. This commit depends on r222957 for read_profile() performing parameter expansion. PR: bin/50569
* sh: Do parameter expansion on ENV before using it.jilles2011-06-102-7/+13
| | | | | | This is required by POSIX, and allows things like ENV=\$HOME/.shrc. Note that tilde expansion is explicitly not performed.
* sh: Do parameter expansion before printing PS4 (set -x).jilles2011-06-095-4/+51
| | | | | | | | | | | | | | | | The function name expandstr() and the general idea of doing this kind of expansion by treating the text as a here document without end marker is from dash. All variants of parameter expansion and arithmetic expansion also work (the latter is not required by POSIX but it does not take extra code and many other shells also allow it). Command substitution is prevented because I think it causes too much code to be re-entered (for example creating an unbounded recursion of trace lines). Unfortunately, our LINENO is somewhat crude, otherwise PS4='$LINENO+ ' would be quite useful.
* sh: Fix $? in heredocs on simple commands.jilles2011-06-051-1/+2
| | | | PR: bin/41410
* sh: Improve error message if the script cannot be opened.jilles2011-06-041-2/+4
| | | | Avoid "<nosuchfile>: cannot open <nosuchfile>: ...".
* sh: Reduce more needless differences between error messages.jilles2011-06-044-5/+5
|
* sh: Honour -n while processing -c string.jilles2011-06-041-1/+1
|
* sh: Remove the "exp" builtin.jilles2011-05-272-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The "exp" builtin is undocumented, non-standard and not very useful. If exp's return value is not used, something like VAR=$(exp EXPRESSION) is equivalent to VAR=$((EXPRESSION)) except that errors in the expression are fatal and quoting special characters is not needed in the latter case. If exp's return value is used, something like if exp EXPRESSION >/dev/null can be replaced by if [ $((EXPRESSION)) -ne 0 ] with similar differences. The exp-run showed that "let" is close enough to bash's and ksh's builtin that removing it would break a few ports. Therefore, "let" remains in 9.x. PR: bin/104432 Exp-run done by: pav (with some other sh(1) changes)
* sh: Correct criterion for using CDPATH in cd.jilles2011-05-271-1/+4
| | | | | | | CDPATH should be ignored not only for pathnames starting with '/' but also for pathnames whose first component is '.' or '..'. The man page already describes this behaviour.
* sh: Various updates to the TOUR document.jilles2011-05-271-29/+8
|
* sh: Fix unquoted $@/$* if IFS=''.jilles2011-05-271-2/+5
| | | | | | If IFS is null, unquoted $@/$* should still expand to separate words. This differs from quoted $@ (which does not depend on IFS) in that pathname generation is performed and empty words are removed.
* sh: Show errno messages in cd.jilles2011-05-251-1/+4
|
* sh: Remove obsolete token type TENDBQUOTE.jilles2011-05-221-1/+0
| | | | | This token type was related to Almquist's original version of backquotes that could not nest and fell into disuse fairly soon.
* Fix some typos under bin/uqs2011-05-221-1/+1
| | | | Found by: codespell
* sh: Fix bss-based buffer overflow in . builtin.jilles2011-05-221-4/+7
| | | | | | | | | | | If the length of a directory in PATH together with the given filename exceeded FILENAME_MAX (which may happen even for pathnames that work), a static buffer was overflown. The static buffer is unnecessary, we can use the stalloc() stack. Obtained from: NetBSD MFC after: 1 week
OpenPOWER on IntegriCloud