summaryrefslogtreecommitdiff
path: root/tools/regression/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* Migrate tools/regression/bin/ tests to the new layout.Julio Merino2013-12-11399-6140/+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: Make <&0 disable the </dev/null implicit in a background command.Jilles Tjoelker2013-11-242-0/+5
| | | | | | | | | Although <&0 does nothing, it is a redirection affecting standard input and should therefore disable the </dev/null redirection implicit in a background command. Notes: svn path=/head/; revision=258535
* sh: Add more tests for the </dev/null implicit in a background command.Jilles Tjoelker2013-11-243-0/+15
| | | | Notes: svn path=/head/; revision=258533
* sh: Add tests for the </dev/null implicit in a background command.Jilles Tjoelker2013-11-223-0/+9
| | | | Notes: svn path=/head/; revision=258489
* 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: Add a test case for would-be assignments that are not due to quoting.Jilles Tjoelker2013-11-101-0/+19
| | | | Notes: svn path=/head/; revision=257920
* 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: Disallow empty simple commands.Jilles Tjoelker2013-08-251-0/+3
| | | | | | | | | | | | | As per POSIX, a simple command must have at least one redirection, assignment word or command word. These occured in rare cases such as eval "f()" . The extension of allowing no commands inside { }, if, while, for, etc. remains. Notes: svn path=/head/; revision=254843
* sh: Reject ++ and -- in arithmetic.Jilles Tjoelker2013-08-241-0/+6
| | | | | | | | | | | | | POSIX does not require ++ and -- in arithmetic. It is probably more useful to reject them than to treat ++x and --x as x silently. Note that the behaviour of increment and decrement can be obtained via (x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1). PR: bin/176444 Notes: svn path=/head/; revision=254806
* 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: Allow a lone redirection before '|', ';;' or ';&'.Jilles Tjoelker2013-08-143-0/+6
| | | | | | | | | | Example: </dev/null | : PR: 181240 MFC after: 1 week Notes: svn path=/head/; revision=254335
* sh: Do not read from stdin if an error occurs during -i -c cmd.Jilles Tjoelker2013-07-121-0/+3
| | | | | | | | | | | | | | | Although using -i with -c does not seem very useful, it seems inappropriate to read commands from the terminal in this case. Side effect: if the -s -c extension is used and the -s option is turned off using 'set +s' during the interactive part, the shell now exits after an error or interrupt. Note that POSIX only specifies -s as option to sh, not to set. See also Austin Group issue #718. Notes: svn path=/head/; revision=253271
* 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: Don't modify exit status when break/continue/return passes !.Jilles Tjoelker2013-04-122-0/+10
| | | | | | | | | | | This matches what would happen if ! P were to be replaced with if P; then false; else true; fi. Example: f() { ! return 0; }; f Notes: svn path=/head/; revision=249407
* 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: Pass $? to command substitution containing compound/multiple commands.Jilles Tjoelker2013-01-141-0/+5
| | | | | | | | Example: false; echo $(echo $?; :) Notes: svn path=/head/; revision=245422
* sh: Add testcase that $? is preserved into a simple command substitution.Jilles Tjoelker2013-01-131-0/+5
| | | | | | | | The test builtins/trap6.0 already uses this but having it separate eases diagnosis if this would break. Notes: svn path=/head/; revision=245392
* sh: Add some testcases related to subshells.Jilles Tjoelker2013-01-135-0/+25
| | | | | | | | These failed in earlier attempts to execute more subshells without forking. The patches are uncommitted. Notes: svn path=/head/; revision=245383
* sh: Fix crash when parsing '{ } &'.Jilles Tjoelker2013-01-131-0/+7
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=245382
* sh: Don't lose $? when backquoted command ends with semicolon or newline.Jilles Tjoelker2013-01-132-0/+10
| | | | | | | | | | | | An empty simple command was added and overwrote the exit status with 0. This affects `...` but not $(...). Example: v=`false;`; echo $? Notes: svn path=/head/; revision=245381
* sh: Detect and flag write errors on stdout in builtins.Jilles Tjoelker2012-12-121-0/+3
| | | | | | | | | | If there is a write error on stdout, a message will be printed (to stderr) and the exit status will be changed to 2 if it would have been 0 or 1. PR: bin/158206 Notes: svn path=/head/; revision=244162
* sh: Apply rlimits to parser/alias10.0 so it fails fast.Jilles Tjoelker2012-11-181-0/+4
| | | | | | | Requested by: uqs Notes: svn path=/head/; revision=243252
* sh: Add tests for modifying an alias (r242766).Jilles Tjoelker2012-11-083-0/+21
| | | | | | | | 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: Test that a redefined alias works.Jilles Tjoelker2012-11-071-0/+6
| | | | Notes: svn path=/head/; revision=242721
* sh: Add some tests for aliasing a utility to itself.Jilles Tjoelker2012-09-222-0/+8
| | | | Notes: svn path=/head/; revision=240825
* sh: Add a simple test for the "local" builtin.Jilles Tjoelker2012-07-151-0/+13
| | | | Notes: svn path=/head/; revision=238469
* sh: Expand assignment-like words specially for export/readonly/local.Jilles Tjoelker2012-07-155-0/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Examples: export x=~ now expands the tilde local y=$1 is now safe, even if $1 contains IFS characters or metacharacters. For a word to "look like an assignment", it must start with a name followed by an equals sign, none of which may be quoted. The special treatment applies when the first word (potentially after "command") is "export", "readonly" or "local". There may be quoting characters but no expansions. If "local" is overridden with a function there is no special treatment ("export" and "readonly" cannot be overridden with a function). If things like local arr=(1 2 3) are ever allowed in the future, they cannot call a "local" function. This would either be a run-time error or it would call the builtin. This matches Austin Group bug #351, planned for the next issue of POSIX.1. PR: bin/166771 Notes: svn path=/head/; revision=238468
* sh: Add tests where "export" does not parse differently.Jilles Tjoelker2012-07-131-0/+13
| | | | | | | | | | | It is planned to expand variable assignments as assignments (no word splitting, different tilde expansion) when they follow a "declaration utility" (export, readonly or local). However, a quoted character cannot be part of a "name" so things like \v=~ are not assignments, and the existing behaviour applies. Notes: svn path=/head/; revision=238430
* 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: Add a test for variables with underscores in arithmetic.Jilles Tjoelker2012-03-111-0/+4
| | | | | | | | Things like $((_x+1)) are broken in stable/8 sh but work in stable/9 and head. Notes: svn path=/head/; revision=232839
* 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