21f23b60 | 21-Aug-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Add case statement fallthrough (with ';&' instead of ';;').
Replacing ;; with the new control operator ;& will cause the next list to be executed as well without checking its pattern, continuing
sh: Add case statement fallthrough (with ';&' instead of ';;').
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.
Obtained-from: FreeBSD 223186
show more ...
|
f15f3668 | 21-Aug-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Reduce unnecessary forks with eval.
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 substitutio
sh: Reduce unnecessary forks with eval.
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.
Obtained-from: FreeBSD 223163
show more ...
|
5b14c76d | 21-Aug-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Fix unquoted $@/$* if IFS=''.
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 perf
sh: Fix unquoted $@/$* if IFS=''.
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.
Obtained-from: FreeBSD 222361
show more ...
|
8c603ea4 | 05-Jul-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Implement the cd -e flag proposed for the next POSIX issue.
This reflects failure to determine the pathname of the new directory in the exit status (1). Normally, cd returns successfully if it d
sh: Implement the cd -e flag proposed for the next POSIX issue.
This reflects failure to determine the pathname of the new directory in the exit status (1). Normally, cd returns successfully if it did chdir() and the call was successful.
In POSIX, -e only has meaning with -P; because our -L is not entirely compliant and may fall back to -P mode, -e has some effect with -L as well.
Obtained-from: FreeBSD SVN rev 222154
show more ...
|
ead7935b | 21-Aug-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Add UTF-8 support to pattern matching.
?, [...] patterns match codepoints instead of bytes. They do not match invalid sequences. [...] patterns must not contain invalid sequences otherwise they
sh: Add UTF-8 support to pattern matching.
?, [...] patterns match codepoints instead of bytes. They do not match invalid sequences. [...] patterns must not contain invalid sequences otherwise they will not match anything. This is so that ${var#?} removes the first codepoint, not the first byte, without putting UTF-8 knowledge into the ${var#pattern} code. However, * continues to match any string and an invalid sequence matches an identical invalid sequence. (This differs from fnmatch(3).)
Obtained-from: FreeBSD SVN rev 221646 & 223010
show more ...
|
e1489450 | 03-Jul-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Add $'quoting' (C-style escape sequences).
A string between $' and ' may contain backslash escape sequences similar to the ones in a C string constant (except that a single-quote must be escaped
sh: Add $'quoting' (C-style escape sequences).
A string between $' and ' may contain backslash escape sequences similar to the ones in a C string constant (except that a single-quote must be escaped and a double-quote need not be). Details are in the sh(1) man page.
This construct is useful to include unprintable characters, tabs and newlines in strings; while this can be done with a command substitution containing a printf command, that needs ugly workarounds if the result is to end with a newline as command substitution removes all trailing newlines.
The construct may also be useful in future to describe unprintable characters without needing to write those characters themselves in 'set -x', 'export -p' and the like.
The implementation attempts to comply to the proposal for the next issue of the POSIX specification. Because this construct is not in POSIX.1-2008, using it in scripts intended to be portable is unwise.
Matching the minimal locale support in the rest of sh, the \u and \U sequences are currently not useful.
Obtained-from: FreeBSD SVN rev 221513
show more ...
|
5d4731c8 | 02-Jul-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Set $? to 0 for background commands.
For backgrounded pipelines and subshells, the previous value of $? was being preserved, which is incorrect.
For backgrounded simple commands containing a co
sh: Set $? to 0 for background commands.
For backgrounded pipelines and subshells, the previous value of $? was being preserved, which is incorrect.
For backgrounded simple commands containing a command substitution, the status of the last command substitution was returned instead of 0.
If fork() fails, this is an error.
Obtained-from: FreeBSD SVN rev 221027
show more ...
|
2b23d27f | 02-Jul-2011 |
Peter Avalos <pavalos@dragonflybsd.org> |
sh: Allow EV_EXIT through function calls.
make {...} <redir more consistent.
If EV_EXIT causes an exit, use the exception mechanism to unwind redirections and local variables. This way, if the fina
sh: Allow EV_EXIT through function calls.
make {...} <redir more consistent.
If EV_EXIT causes an exit, use the exception mechanism to unwind redirections and local variables. This way, if the final command is a redirected command, an EXIT trap now executes without the redirections.
Because of these changes, EV_EXIT can now be inherited by the body of a function, so do so. This means that a function no longer prevents a fork before an exec being skipped, such as in f() { head -1 /etc/passwd; }; echo $(f)
Wrapping a single builtin in a function may still cause an otherwise unnecessary fork with command substitution, however.
An exit command or -e failure still invokes the EXIT trap with the original redirections and local variables in place.
Note: this depends on SHELLPROC being gone. A SHELLPROC depended on keeping the redirections and local variables and only cleaning up the state to restore them.
Obtained-from: FreeBSD SVN rev 220978
show more ...
|