summaryrefslogtreecommitdiffstats
path: root/tools/regression/bin/sh/builtins
Commit message (Collapse)AuthorAgeFilesLines
* Migrate tools/regression/bin/ tests to the new layout.jmmv2013-12-11152-2322/+0
| | | | | | | | | | | | | | | | | | | | This change is a proof of concept on how to easily integrate existing tests from the tools/regression/ hierarchy into the /usr/tests/ test suite and on how to adapt them to the new layout for src. To achieve these goals, this change: - Moves tests from tools/regression/bin/<tool>/ to bin/<tool>/tests/. - Renames the previous regress.sh files to legacy_test.sh. - Adds Makefiles to build and install the tests and all their supporting data files into /usr/tests/bin/. - Plugs the legacy_test test programs into the test suite using the new TAP backend for Kyua (appearing in 0.8) so that the code of the test programs does not have to change. - Registers the new directories in the BSD.test.dist mtree file. Reviewed by: freebsd-testing Approved by: rpaulo (mentor)
* sh: Properly quote alias output from command -v.jilles2013-11-101-0/+7
| | | | | An alias should be printed by command -v as a command line; therefore, make the alias definition suitable for re-input to the shell.
* sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'.jilles2013-10-302-0/+18
| | | | | | | | | | | | | | If job control is not enabled, background jobs started with ... & ignore SIGINT and SIGQUIT so that they are not affected by such signals that are intended for the foreground job. However, this should not prevent reassigning a different action for these signals (as if the shell invocation inherited these signal actions from its parent). Austin group issue #751 Example: { trap - INT; exec sleep 10; } & wait A Ctrl+C should terminate the sleep command.
* sh: Make return return from the closest function or dot script.jilles2013-09-041-0/+13
| | | | | | | | | | | | | Formerly, return always returned from a function if it was called from a function, even if there was a closer dot script. This was for compatibility with the Bourne shell which only allowed returning from functions. Other modern shells and POSIX return from the function or the dot script, whichever is closest. Git 1.8.4's rebase --continue depends on the POSIX behaviour. Reported by: Christoph Mallon, avg
* sh: Recognize "--" as end of options in type builtin.jilles2013-08-301-0/+3
| | | | | This implementation makes minimal changes: command names starting with "-" (other than "--") can still be queried normally.
* sh: Recognize "--" as end of options in alias builtin.jilles2013-08-251-0/+4
| | | | | Aliases starting with "-" (which are non-POSIX) will need to be preceded by an alias not starting with "-" or the newly added "--".
* sh: Recognize "--" as end of options in bg/fg/jobid builtins.jilles2013-08-161-0/+9
|
* sh: Add test for the non-standard jobid builtin.jilles2013-08-161-0/+7
|
* sh: Recognize "--" as end of options in local builtin.jilles2013-08-141-0/+12
|
* sh: Add tests for 'local -' (save shell options).jilles2013-06-152-0/+43
|
* sh: Return status 127 for unknown jobs in wait builtin.jilles2013-06-052-0/+8
| | | | | | | | | | This is required by POSIX, at least for pids that are not known child processes. Other problems with job specifications still cause wait to abort with exit status 2. PR: 176916
* sh: Allow multiple operands in wait builtin.jilles2013-06-051-0/+7
| | | | | | | | This is only part of the PR; the behaviour for unknown/invalid pids/jobs remains unchanged (aborts the builtin with status 2). PR: 176916 Submitted by: Vadim Goncharov
* sh: Add test cases for break outside a loop.jilles2013-05-312-0/+19
| | | | | | In most shells (including our sh), break outside a loop does nothing with status 0, or at least does not abort. Therefore, scripts sometimes (buggily) depend on this.
* sh: Remove racy test case for read builtin.jilles2013-05-031-13/+0
| | | | | | | This test case sometimes fails because of an EINTR-related race condition. Fixing this race condition likely requires an extra system call per byte, which would make the read builtin even slower than it already is, or very complicated trickery. Therefore, remove the test case for now.
* sh: Improve error handling in read builtin:jilles2013-05-032-0/+18
| | | | | | | | | | | | * If read -t times out, return status as if interrupted by SIGALRM (formerly 1). * If a trapped signal interrupts read, return status 128+sig (formerly 1). * If [EINTR] occurs but there is no trap, retry the read (for example because of a SIGWINCH in interactive mode). * If a read error occurs, write an error message and return status 2. As before, a variable assignment error returns 2 and discards the remaining data read.
* sh: Add a variation on builtins/eval4.0 where the cmdsubst returns 0.jilles2013-04-061-0/+5
|
* sh: Recognize "--" and explicitly reject options in wait builtin.jilles2013-03-152-0/+7
| | | | | | If syntactically invalid job identifiers are to be taken as jobs that exited with status 127, this should not apply to options, so that we can add options later if need be.
* sh: When executing a trap, keep exit status along with evalskip.jilles2013-03-031-0/+10
| | | | | | | This ensures 'return' in a trap returns the correct status to the caller. If evalskip is not set or if it is overridden by a previous evalskip, keep the old behaviour of restoring the exit status from before the trap.
* sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig.jilles2013-02-232-0/+24
|
* sh: Test that the exit status is 1 if read encounters EOF.jilles2013-02-231-0/+5
|
* sh: Add tests for modifying an alias (r242766).jilles2012-11-082-0/+16
| | | | | Note: parser/alias10.0 will eat a lot of memory/cpu time when it fails (with the old sh).
* sh: Add a simple test for the "local" builtin.jilles2012-07-151-0/+13
|
* sh: Do not assume that SIGPIPE will only kill a subshell in builtins/wait3.0jilles2012-06-081-1/+1
| | | | | | | | | | | | | | test. POSIX says that SIGPIPE affects a process and therefore a SIGPIPE caused and received by a subshell environment may or may not affect the parent shell environment. The change assumes that ${SH} is executed in a new process. This must be the case if it contains a slash and everyone appears to do so anyway even though POSIX might permit otherwise. This change makes builtins/wait3.0 work in ksh93.
* sh: Make 'hash' return 1 if at least one utility is not found.jilles2012-02-111-0/+6
| | | | Reported by: lme
* sh: Fix $? in the first command of a 'for'.jilles2012-01-222-0/+17
| | | | | | 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: Fix execution of multiple statements in a trap when evalskip is setdumbbell2012-01-162-0/+14
| | | | | | | | | | | 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: Test EXIT trap with multiple statements in itdumbbell2012-01-161-0/+3
| | | | | Reviewed by: jilles MFC after: 2 weeks
* sh: Fix some bugs with exit status from case containing ;&.jilles2012-01-153-0/+17
| | | | | | | | | | | | | 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-153-0/+17
| | | | | | | * 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: Properly show "Not a directory" error in cd builtin.jilles2012-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
* sh: Avoid possible echo options in a testcase.jilles2012-01-061-3/+3
|
* Spelling fixes for tools/uqs2011-12-301-1/+1
| | | | Add some $FreeBSD$ tags so svn will allow the commit.
* sh: Allow quoting ^ and ] in bracket expressions.jilles2011-12-281-0/+12
|
* sh: Add tests for some corner cases of 'case' exit status.jilles2011-11-262-0/+12
| | | | These already work properly.
* sh: Add test for exit status of for loop without items.jilles2011-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.
* sh: Test that '!' is literal if quoted and first char of bracket expressionjilles2011-06-251-0/+16
| | | | This also works on stable/8.
* sh: Add case statement fallthrough (with ';&' instead of ';;').jilles2011-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.
* sh: Skip variables with invalid names in "set", "export -p", "readonly -p".jilles2011-06-172-0/+6
| | | | This ensures the output of these commands is valid shell input.
* sh: Add support for named character classes in bracket expressions.jilles2011-06-151-0/+32
| | | | | Example: case x in [[:alpha:]]) echo yes ;; esac
* sh: Add test for LC_COLLATE-based character ranges in case.jilles2011-06-121-0/+24
|
* sh: Add test for case pattern matching with iso-8859-1 charset.jilles2011-06-121-0/+52
| | | | This also passes on stable/8.
* sh: Reduce more needless differences between error messages.jilles2011-06-041-1/+1
|
* sh: Add test for 'set +o'.jilles2011-05-291-0/+32
|
* sh: Correct criterion for using CDPATH in cd.jilles2011-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.
* sh: Add simple CDPATH test.jilles2011-05-271-0/+23
|
* sh: Add test for r222173.jilles2011-05-221-0/+12
|
* sh: Implement the cd -e flag proposed for the next POSIX issue.jilles2011-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.
* sh: Add UTF-8 support to pattern matching.jilles2011-05-081-0/+57
| | | | | | | | | | ?, [...] 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).)
* sh: Add test for bin/56147.jilles2011-04-151-0/+6
|
* sh: Test that . /dev/null returns exit status 0 and does not preserve $?.jilles2011-03-071-0/+10
| | | | | | | Preserving $? may cause problems particularly if set -e is in effect. It may be useful to preserve the old value of $? in the dot script but this must not be implemented in such a way that it would break this test.
OpenPOWER on IntegriCloud