summaryrefslogtreecommitdiffstats
path: root/tools/regression/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* Sync sh(1) in stable/10 to head.jmmv2014-03-09387-6067/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a MFC of all the commits listed below. My original goal of this change was to only merge the move of the tests from tools/regression/bin/ into the new layout (which include tests for sh(1) and other tools as well). However, doing so is tricky due to the ongoing work in sh(1) and, especially, the many changes to its tests since stable/10 was first branched. Merging everything is the simplest way to achieve this goal and, as a bonus point, we get various fixes and miscellaneous improvements into the branch. Per jilles' suggestion, I'm avoiding the merge of a couple of changes (r256850 and r257506) that required depending kernel changes. I'm also avoiding very recent changes that have not had a long enough time to be validated in current. This is "make tinderbox" clean. r256735 sh: Remove one syscall when waiting for a foreground job. r257399 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'. r257504 sh: Reorder union node to reduce its size on 64-bit platforms. r257920 sh: Add a test case for would-be assignments that are not due to quoting. r257929 sh: Properly quote alias output from command -v. r258489 sh: Add tests for the </dev/null implicit in a background command. r258533 sh: Add more tests for the </dev/null implicit in a background command. r258535 sh: Make <&0 disable the </dev/null implicit in a background command. r258776 sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro. r259047 sh: Split set -x output into a separate function. r259210 Migrate tools/regression/bin/ tests to the new layout. r259844 sh: Remove an unused variable. r259846 sh: Initialize OPTIND=1 even if it came from the environment. r259874 sh: Simplify code related to PPID variable. r259946 sh: Don't check input for non-whitespace if history is disabled. r260246 sh(1): Discourage use of -e. r260506 Run the sh(1) and test(1) tests as unprivileged. r260586 Mark the bin/pax tests as requiring perl. r260634 Use TAP_TESTS_PERL to register the legacy_test in bin/pax. r260635 Replace hand-crafted Kyuafiles with automatic generation. r260654 sh: Remove SIGWINCH handler and just check for resize before every read. r261121 sh: Add test for nested alias. r261125 sh: Solve the alias recursion problem in a less hackish way. r261141 sh: Do not depend on parse/execute split in new alias test. r261160 sh: Add tests for alias names after another alias. r261192 sh: Allow aliases to force alias substitution on the following word. r262533 sh: Make expari() static. r262565 sh: Do not corrupt internal representation if LINENO inner expansion fails. r262697 sh: Simplify expari(). Reviewed by: jilles
* 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: Disallow empty simple commands.jilles2013-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.
* sh: Reject ++ and -- in arithmetic.jilles2013-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
* 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: Allow a lone redirection before '|', ';;' or ';&'.jilles2013-08-143-0/+6
| | | | | | | Example: </dev/null | : PR: 181240 MFC after: 1 week
* sh: Do not read from stdin if an error occurs during -i -c cmd.jilles2013-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.
* 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: Don't modify exit status when break/continue/return passes !.jilles2013-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
* 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: Pass $? to command substitution containing compound/multiple commands.jilles2013-01-141-0/+5
| | | | | Example: false; echo $(echo $?; :)
* sh: Add testcase that $? is preserved into a simple command substitution.jilles2013-01-131-0/+5
| | | | | The test builtins/trap6.0 already uses this but having it separate eases diagnosis if this would break.
* sh: Add some testcases related to subshells.jilles2013-01-135-0/+25
| | | | | These failed in earlier attempts to execute more subshells without forking. The patches are uncommitted.
* sh: Fix crash when parsing '{ } &'.jilles2013-01-131-0/+7
| | | | MFC after: 1 week
* sh: Don't lose $? when backquoted command ends with semicolon or newline.jilles2013-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 $?
* sh: Detect and flag write errors on stdout in builtins.jilles2012-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
* sh: Apply rlimits to parser/alias10.0 so it fails fast.jilles2012-11-181-0/+4
| | | | Requested by: uqs
* sh: Add tests for modifying an alias (r242766).jilles2012-11-083-0/+21
| | | | | Note: parser/alias10.0 will eat a lot of memory/cpu time when it fails (with the old sh).
* sh: Test that a redefined alias works.jilles2012-11-071-0/+6
|
* sh: Add some tests for aliasing a utility to itself.jilles2012-09-222-0/+8
|
* sh: Add a simple test for the "local" builtin.jilles2012-07-151-0/+13
|
* sh: Expand assignment-like words specially for export/readonly/local.jilles2012-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
* sh: Add tests where "export" does not parse differently.jilles2012-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.
* 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: Add a test for variables with underscores in arithmetic.jilles2012-03-111-0/+4
| | | | | Things like $((_x+1)) are broken in stable/8 sh but work in stable/9 and head.
* 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: Add testcases that should not be broken by future optimizations.jilles2012-01-142-0/+18
|
* 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 some testcases for pasting $*/$@ directly to a literal.jilles2011-12-251-0/+65
| | | | This also passes on stable/8.
OpenPOWER on IntegriCloud