aboutsummaryrefslogtreecommitdiff
path: root/tools/regression/bin/sh/builtins
Commit message (Collapse)AuthorAgeFilesLines
* Migrate tools/regression/bin/ tests to the new layout.Julio Merino2013-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) Notes: svn path=/head/; revision=259210
* sh: Properly quote alias output from command -v.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=257929
* sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=257399
* sh: Make return return from the closest function or dot script.Jilles Tjoelker2013-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 Notes: svn path=/head/; revision=255215
* sh: Recognize "--" as end of options in type builtin.Jilles Tjoelker2013-08-301-0/+3
| | | | | | | | This implementation makes minimal changes: command names starting with "-" (other than "--") can still be queried normally. Notes: svn path=/head/; revision=255072
* sh: Recognize "--" as end of options in alias builtin.Jilles Tjoelker2013-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 "--". Notes: svn path=/head/; revision=254849
* sh: Recognize "--" as end of options in bg/fg/jobid builtins.Jilles Tjoelker2013-08-161-0/+9
| | | | Notes: svn path=/head/; revision=254413
* sh: Add test for the non-standard jobid builtin.Jilles Tjoelker2013-08-161-0/+7
| | | | Notes: svn path=/head/; revision=254412
* sh: Recognize "--" as end of options in local builtin.Jilles Tjoelker2013-08-141-0/+12
| | | | Notes: svn path=/head/; revision=254339
* sh: Add tests for 'local -' (save shell options).Jilles Tjoelker2013-06-152-0/+43
| | | | Notes: svn path=/head/; revision=251797
* sh: Return status 127 for unknown jobs in wait builtin.Jilles Tjoelker2013-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 Notes: svn path=/head/; revision=251430
* sh: Allow multiple operands in wait builtin.Jilles Tjoelker2013-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 Notes: svn path=/head/; revision=251429
* sh: Add test cases for break outside a loop.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=251180
* sh: Remove racy test case for read builtin.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=250222
* sh: Improve error handling in read builtin:Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=250214
* sh: Add a variation on builtins/eval4.0 where the cmdsubst returns 0.Jilles Tjoelker2013-04-061-0/+5
| | | | Notes: svn path=/head/; revision=249220
* sh: Recognize "--" and explicitly reject options in wait builtin.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=248349
* sh: When executing a trap, keep exit status along with evalskip.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=247720
* sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig.Jilles Tjoelker2013-02-232-0/+24
| | | | Notes: svn path=/head/; revision=247206
* sh: Test that the exit status is 1 if read encounters EOF.Jilles Tjoelker2013-02-231-0/+5
| | | | Notes: svn path=/head/; revision=247190
* sh: Add tests for modifying an alias (r242766).Jilles Tjoelker2012-11-082-0/+16
| | | | | | | | Note: parser/alias10.0 will eat a lot of memory/cpu time when it fails (with the old sh). Notes: svn path=/head/; revision=242767
* sh: Add a simple test for the "local" builtin.Jilles Tjoelker2012-07-151-0/+13
| | | | Notes: svn path=/head/; revision=238469
* sh: Do not assume that SIGPIPE will only kill a subshell in builtins/wait3.0Jilles Tjoelker2012-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. Notes: svn path=/head/; revision=236771
* sh: Make 'hash' return 1 if at least one utility is not found.Jilles Tjoelker2012-02-111-0/+6
| | | | | | | Reported by: lme Notes: svn path=/head/; revision=231535
* sh: Fix $? in the first command of a 'for'.Jilles Tjoelker2012-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. Notes: svn path=/head/; revision=230463
* sh: Fix execution of multiple statements in a trap when evalskip is setJean-Sébastien Pédron2012-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 Notes: svn path=/head/; revision=230212
* sh: Test EXIT trap with multiple statements in itJean-Sébastien Pédron2012-01-161-0/+3
| | | | | | | | Reviewed by: jilles MFC after: 2 weeks Notes: svn path=/head/; revision=230211
* sh: Fix some bugs with exit status from case containing ;&.Jilles Tjoelker2012-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 $?. Notes: svn path=/head/; revision=230161
* sh: Fix two bugs with case and exit status:Jilles Tjoelker2012-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. Notes: svn path=/head/; revision=230154
* 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 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: 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: 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 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: 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: Reduce more needless differences between error messages.Jilles Tjoelker2011-06-041-1/+1
| | | | Notes: svn path=/head/; revision=222684
* 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: Add test for r222173.Jilles Tjoelker2011-05-221-0/+12
| | | | Notes: svn path=/head/; revision=222174
* 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: Add UTF-8 support to pattern matching.Jilles Tjoelker2011-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).) Notes: svn path=/head/; revision=221646
* sh: Add test for bin/56147.Jilles Tjoelker2011-04-151-0/+6
| | | | Notes: svn path=/head/; revision=220654
* sh: Test that . /dev/null returns exit status 0 and does not preserve $?.Jilles Tjoelker2011-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. Notes: svn path=/head/; revision=219390