aboutsummaryrefslogtreecommitdiff
path: root/tools/regression/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
...
* sh: Add testcases that should not be broken by future optimizations.Jilles Tjoelker2012-01-142-0/+18
| | | | Notes: svn path=/head/; revision=230121
* sh: Properly show "Not a directory" error in cd builtin.Jilles Tjoelker2012-01-131-0/+26
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=230095
* sh: Avoid possible echo options in a testcase.Jilles Tjoelker2012-01-061-3/+3
| | | | Notes: svn path=/head/; revision=229742
* Spelling fixes for tools/Ulrich Spörlein2011-12-301-1/+1
| | | | | | | Add some $FreeBSD$ tags so svn will allow the commit. Notes: svn path=/head/; revision=228975
* sh: Allow quoting ^ and ] in bracket expressions.Jilles Tjoelker2011-12-281-0/+12
| | | | Notes: svn path=/head/; revision=228943
* sh: Add some testcases for pasting $*/$@ directly to a literal.Jilles Tjoelker2011-12-251-0/+65
| | | | | | | This also passes on stable/8. Notes: svn path=/head/; revision=228873
* sh: Add tests for some corner cases of 'case' exit status.Jilles Tjoelker2011-11-262-0/+12
| | | | | | | These already work properly. Notes: svn path=/head/; revision=228007
* sh: Allow unsetting OPTIND.Jilles Tjoelker2011-11-201-0/+3
| | | | | | | Note that only assigning the decimal value 1 resets getopts, as before. Notes: svn path=/head/; revision=227773
* sh: Add test for exit status of for loop without items.Jilles Tjoelker2011-10-281-0/+4
| | | | | | | | | POSIX says the exit status of a for loop without any items shall be 0. There are no exceptions if the exit status of the previous command was not 0 or if the item list contains a command substitution with non-zero exit status. Notes: svn path=/head/; revision=226892
* sh: Add a test for a fairly obscure case with aliases.Jilles Tjoelker2011-07-161-0/+6
| | | | | | | This also passes on stable/8. Notes: svn path=/head/; revision=224104
* sh: Test that '!' is literal if quoted and first char of bracket expressionJilles Tjoelker2011-06-251-0/+16
| | | | | | | This also works on stable/8. Notes: svn path=/head/; revision=223546
* sh: Add test for r223282.Jilles Tjoelker2011-06-191-0/+6
| | | | Notes: svn path=/head/; revision=223283
* sh: Add case statement fallthrough (with ';&' instead of ';;').Jilles Tjoelker2011-06-171-0/+39
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=223186
* sh: Skip variables with invalid names in "set", "export -p", "readonly -p".Jilles Tjoelker2011-06-172-0/+6
| | | | | | | This ensures the output of these commands is valid shell input. Notes: svn path=/head/; revision=223183
* sh: Reduce unnecessary forks with eval.Jilles Tjoelker2011-06-161-0/+5
| | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=223163
* sh: Add support for named character classes in bracket expressions.Jilles Tjoelker2011-06-151-0/+32
| | | | | | | | Example: case x in [[:alpha:]]) echo yes ;; esac Notes: svn path=/head/; revision=223120
* sh: Add test for LC_COLLATE-based character ranges in case.Jilles Tjoelker2011-06-121-0/+24
| | | | Notes: svn path=/head/; revision=223011
* sh: Add test for case pattern matching with iso-8859-1 charset.Jilles Tjoelker2011-06-121-0/+52
| | | | | | | This also passes on stable/8. Notes: svn path=/head/; revision=223007
* sh: Do parameter expansion on ENV before using it.Jilles Tjoelker2011-06-101-0/+11
| | | | | | | | | This is required by POSIX, and allows things like ENV=\$HOME/.shrc. Note that tilde expansion is explicitly not performed. Notes: svn path=/head/; revision=222957
* sh: Do parameter expansion before printing PS4 (set -x).Jilles Tjoelker2011-06-091-0/+9
| | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=222907
* sh: Add simple tests for set -x and PS4.Jilles Tjoelker2011-06-082-0/+17
| | | | Notes: svn path=/head/; revision=222882
* sh: Fix $? in heredocs on simple commands.Jilles Tjoelker2011-06-051-0/+15
| | | | | | | PR: bin/41410 Notes: svn path=/head/; revision=222716
* sh: Add already working testcases for $? in here-document.Jilles Tjoelker2011-06-051-0/+25
| | | | | | | | | | | | If the here-document is attached to a compound command or subshell, $? already works properly. This is both a workaround for bin/41410 and a requirement for a true fix for bin/41410. PR: bin/41410 MFC after: 1 week Notes: svn path=/head/; revision=222715
* sh: Reduce more needless differences between error messages.Jilles Tjoelker2011-06-041-1/+1
| | | | Notes: svn path=/head/; revision=222684
* sh: Honour -n while processing -c string.Jilles Tjoelker2011-06-041-0/+3
| | | | Notes: svn path=/head/; revision=222676
* sh: Add tests for -n flag. These already pass.Jilles Tjoelker2011-06-033-0/+16
| | | | Notes: svn path=/head/; revision=222661
* sh: Add tests for some somewhat obscure aspects of function definitions.Jilles Tjoelker2011-05-302-0/+12
| | | | Notes: svn path=/head/; revision=222512
* sh: Add test for 'set +o'.Jilles Tjoelker2011-05-291-0/+32
| | | | Notes: svn path=/head/; revision=222451
* sh: Correct criterion for using CDPATH in cd.Jilles Tjoelker2011-05-272-0/+25
| | | | | | | | | | 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. Notes: svn path=/head/; revision=222381
* sh: Add simple CDPATH test.Jilles Tjoelker2011-05-271-0/+23
| | | | Notes: svn path=/head/; revision=222379
* sh: Fix unquoted $@/$* if IFS=''.Jilles Tjoelker2011-05-271-0/+39
| | | | | | | | | 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. Notes: svn path=/head/; revision=222361
* sh: Add test for r222173.Jilles Tjoelker2011-05-221-0/+12
| | | | Notes: svn path=/head/; revision=222174
* sh: Expand aliases after assignments and redirections.Jilles Tjoelker2011-05-212-0/+10
| | | | Notes: svn path=/head/; revision=222165
* sh: Add test for positional parameters with more than one digit.Jilles Tjoelker2011-05-211-0/+13
| | | | | | | This also passes on stable/8. Notes: svn path=/head/; revision=222158
* sh: Implement the cd -e flag proposed for the next POSIX issue.Jilles Tjoelker2011-05-202-0/+59
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=222154
* sh: Allow terminating a heredoc with a terminator at EOF without a newline.Jilles Tjoelker2011-05-201-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | This is sometimes used with eval or old-style command substitution, and most shells other than ash derivatives allow it. It can also be used with scripts that violate POSIX's requirement on the application that they end in a newline (scripts must be text files except that line length is unlimited). Example: v=`cat <<EOF foo EOF` echo $v This commit does not add support for the similar construct with new-style command substitution, like v=$(cat <<EOF foo EOF) This continues to require a newline after the terminator. Notes: svn path=/head/; revision=222134
* sh: Add tests for lines that look like heredoc delimiters but are not.Jilles Tjoelker2011-05-142-0/+107
| | | | Notes: svn path=/head/; revision=221887
* sh: Add \u/\U support (in $'...') for UTF-8.Jilles Tjoelker2011-05-082-0/+18
| | | | | | | | | | | | | Because we have no iconv in base, support for other charsets is not possible. Note that \u/\U are processed using the locale that was active when the shell started. This is necessary to avoid behaviour that depends on the parse/execute split (for example when placing braces around an entire script). Therefore, UTF-8 encoding is implemented manually. Notes: svn path=/head/; revision=221669
* sh: Add UTF-8 support to pattern matching.Jilles Tjoelker2011-05-082-0/+132
| | | | | | | | | | | | | ?, [...] 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).) Notes: svn path=/head/; revision=221646
* sh: Add UTF-8 support to ${#var}.Jilles Tjoelker2011-05-072-0/+28
| | | | | | | | If the current locale uses UTF-8, ${#var} counts codepoints (more precisely, bytes b with (b & 0xc0) != 0x80). Notes: svn path=/head/; revision=221602
* sh: Add $'quoting' (C-style escape sequences).Jilles Tjoelker2011-05-059-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Exp-run done by: pav (with some other sh(1) changes) Notes: svn path=/head/; revision=221513
* sh: Apply set -u to variables in arithmetic.Jilles Tjoelker2011-05-041-0/+6
| | | | | | | | | | Note that this only applies to variables that are actually used. Things like (0 && unsetvar) do not cause an error. Exp-run done by: pav (with some other sh(1) changes) Notes: svn path=/head/; revision=221463
* sh: Detect an error for ${#var<GARBAGE>}.Jilles Tjoelker2011-05-042-0/+3
| | | | | | | | | | | | In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors rather than silent equivalents of ${#foo}. PR: bin/151720 Submitted by: Mark Johnston Exp-run done by: pav (with some other sh(1) changes) Notes: svn path=/head/; revision=221461
* sh: Set $? to 0 for background commands.Jilles Tjoelker2011-04-253-0/+13
| | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=221027
* sh: Allow EV_EXIT through function calls, make {...} <redir more consistent.Jilles Tjoelker2011-04-233-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=220978
* sh: Do not word split "${#parameter}".Jilles Tjoelker2011-04-201-0/+8
| | | | | | | | | | | | | | | | This is only a problem if IFS contains digits, which is unusual but valid. Because of an incorrect fix for PR bin/12137, "${#parameter}" was treated as ${#parameter}. The underlying problem was that "${#parameter}" erroneously added CTLESC bytes before determining the length. This was properly fixed for PR bin/56147 but the incorrect fix was not backed out. Reported by: Seeker on forums.freebsd.org MFC after: 2 weeks Notes: svn path=/head/; revision=220903
* sh: Add test for bin/12137.Jilles Tjoelker2011-04-151-0/+27
| | | | Notes: svn path=/head/; revision=220656
* sh: Add test for obscure and ambiguous ${#?}.Jilles Tjoelker2011-04-151-0/+11
| | | | Notes: svn path=/head/; revision=220655
* sh: Add test for bin/56147.Jilles Tjoelker2011-04-151-0/+6
| | | | Notes: svn path=/head/; revision=220654
* sh: Fix some parameter expansion variants ${#...}.Jilles Tjoelker2011-03-132-0/+21
| | | | | | | | | | | | These already worked: $# ${#} ${##} ${#-} ${#?} These now work as well: ${#+word} ${#-word} ${##word} ${#%word} There is an ambiguity in the standard with ${#?}: it could be the length of $? or it could be $# giving an error in the (impossible) case that it is not set. We continue to use the former interpretation as it seems more useful. Notes: svn path=/head/; revision=219623