summaryrefslogtreecommitdiffstats
path: root/bin/sh/tests
Commit message (Collapse)AuthorAgeFilesLines
* DIRDEPS_BUILD: Connect MK_TESTS.bdrewery2016-03-098-0/+88
| | | | Sponsored by: EMC / Isilon Storage Division
* sh: Add test for 'set -o nolog'.jilles2016-03-092-0/+5
| | | | | The option does not do anything so check that the output of 'set +o' is different.
* sh: Fix set -v and multiline history after r295825.jilles2016-02-233-0/+14
| | | | | | | r295825 erroneously dropped the newline from the input data for 'set -v' output and multiline history. Reported by: vangyzen
* sh: Rework code to remove '\0' from shell input.jilles2016-02-192-0/+13
| | | | | This fixes bugs where '\0' was not removed correctly and speeds up the parser.
* sh: Add tests for comments in sh -c.jilles2016-02-193-0/+9
|
* Test directories can build in parallel fine.bdrewery2016-02-161-2/+0
| | | | Sponsored by: EMC / Isilon Storage Division
* sh: Clean a readonly local, even if the variable does not exist outside.jilles2016-01-222-0/+11
| | | | | If a local variable has been made read-only, this should not prevent its removal when the function returns.
* sh: Add already working test for local-readonly interaction.jilles2016-01-222-0/+11
|
* sh: Update associated state when restoring locals while leaving a function.jilles2016-01-102-0/+16
| | | | | | | | Some variables like PATH call a function when modified. Make sure to call this also when leaving a function where such a variable was made local. Make sure to restore local variables before shellparam, so getopts state is not clobbered.
* sh: Add a test for 'cd -'.jilles2016-01-073-0/+11
| | | | | | Redirect 'cd -' output to /dev/null since POSIX requires it to write the new directory name even if not interactive, but we currently only write it if interactive.
* sh: Ensure OPTIND=1 in subshell without forking does not affect outer env.jilles2016-01-072-0/+12
| | | | | | | | | | | | Command substitutions containing a single simple command and here-document expansion are performed in a subshell environment, but may not fork. Any modified state of the shell environment should be restored afterward. The state that OPTIND=1 had been done was not saved and restored here. Note that the other parts of shellparam need not be saved and restored, since they are not modified in these situations (a fork is done before such modifications).
* sh: Link tests/builtins/getopts9.0 to the build.jilles2016-01-031-0/+1
| | | | This was forgotten in r273700.
* sh: Add tests for #/##/%/%% on $* and $@.jilles2015-12-262-0/+62
| | | | | Although POSIX leaves things like ${*#X} unspecified, it occasionally occurs in practice. Add some tests that seem to work sensibly.
* sh: Add limited test for ${#@} and ${#*}.jilles2015-12-062-0/+19
| | | | | POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure it is numeric.
* sh: Link tests/parameters/positional8.0 to the build.jilles2015-12-051-0/+1
| | | | This was forgotten in r291025.
* sh: Fix ""$@, which should not use the special case for "$@".jilles2015-11-181-0/+31
| | | | | "$@" should expand to no words if there are no positional parameters, but ""$@ should always expand to at least an empty word.
* Add more SUBDIR_PARALLEL.bdrewery2015-10-151-0/+2
| | | | | MFC after: 3 weeks Sponsored by: EMC / Isilon Storage Division
* Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) andngie2015-10-121-2/+0
| | | | | | | | | | | | netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Divison
* sh: Allow empty << EOF markers.jilles2015-09-022-0/+22
|
* sh: Fix read with escaped IFS characters at the end.jilles2015-08-302-0/+11
| | | | | Characters escaped with a backslash must be treated as if they were not in IFS. This includes stripping trailing IFS characters.
* sh: Fix out of bounds read when there is no ] after a [:class:].jilles2015-08-252-0/+10
| | | | | | | | | | | The initial check for a matching ] was incorrect if a ] may be consumed by a [:class:]. The subsequent loop assumed that there must be a ]. Remove the initial check and make the loop cope with a missing ]. Found with afl-fuzz. MFC after: 1 week
* sh: Don't create bad parse result when postponing a bad substitution error.jilles2015-08-233-0/+10
| | | | | | | | | | | | | | An invalid substitution like ${var@} does not cause a parse error but is stored in the intermediate representation, to be written as part of the error message. If there is a CTL* byte in the stored part, this confuses some code such as the code to skip an unused alternative such as in ${var-alternative}. To keep things simple, do not store CTL* bytes. Found with afl-fuzz. MFC after: 1 week
* sh: Avoid negative character values from $'\Uffffffff' etc.jilles2015-08-202-0/+9
| | | | | | | | | The negative value was not expected and generated the low 8 bits as a byte, which may be an invalid character encoding. The final shift in creating the negative value was undefined as well. Make the temporary variable unsigned to fix this.
* sh: Add test for $'\u' without any digits.jilles2015-08-202-0/+8
| | | | | It is likely that $'\uXXXX' and $'\UXXXXXXXX' will allow fewer digits in future. However, no digits at all should still be disallowed.
* sh: Backslash-newline should not affect field splitting in read builtin.jilles2015-08-162-0/+18
| | | | This was originally broken in r212339 in 2010.
* sh: Fix the trap builtin to be POSIX-compliant for 'trap exit SIG' and 'trap ↵bdrewery2015-04-183-0/+27
| | | | | | | | | | | | | | | | | n n...'. The parser considered 'trap exit INT' to reset the default for both EXIT and INT. This beahvior is not POSIX compliant. This was avoided if a value was specified for 'exit', but then disallows exiting with the signal received. A possible workaround is using ' exit'. However POSIX does allow this type of behavior if the parameters are all integers. Fix the handling for this and clarify its support in the manpage since it is specifically allowed by POSIX. Differential Revision: https://reviews.freebsd.org/D2325 Reviewed by: jilles MFC after: 2 weeks
* sh: Add more tests for exotic IFS splitting.jilles2015-03-313-0/+13
|
* sh: Add simple tests for globbing/splitting command substitution.jilles2015-02-153-0/+9
|
* sh: Make sure output suitable as shell input is also printable.jilles2014-12-142-0/+8
| | | | | | | | | | | Commands like 'export -p', 'set' and 'trap', and tracing enabled via 'set -x' generate output suitable as shell input by adding quotes as necessary. If there are control characters other than newline or invalid UTF-8 sequences, use $'...' and \OOO to display them safely. The resulting output is not parsable by a strict POSIX.1-2008 shell but sh from FreeBSD 9.0 and newer and many other shells can parse it.
* sh: Fix corruption of CTL* bytes in positional parameters in redirection.jilles2014-10-312-0/+27
| | | | | | | EXP_REDIR was not being checked for while expanding positional parameters in redirection, so CTL* bytes were not being prefixed where they should be. MFC after: 1 week
* Treat IFS separators in "$*" as quoted.jilles2014-10-283-0/+17
| | | | This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
* sh: Make getopts memory-safe if with changing arguments.jilles2014-10-262-0/+12
| | | | | | | | | | | | POSIX does not permit to continuing a getopts loop with different arguments. For parsing the positional parameters, we handle this case by resetting the getopts state when the positional parameters are changed in any way (and the getopts state is local to a function). However, in the syntax getopts <optstring> <var> <arg...>, changes could lead to invalid memory access. In the syntax getopts <optstring> <var> <arg...>, store a copy of the arguments and continue to use them until getopts is reset.
* sh: Allow backslash-newline continuation in more places:jilles2014-10-199-0/+113
| | | | | | | * directly after a $ * directly after ${ * between the characters of a multi-character operator token * within a parameter name
* sh: Add some tests for backslash-newline continuation.jilles2014-10-174-0/+30
|
* sh: Fix break/continue/return in multiline eval.jilles2014-10-123-0/+18
| | | | | Example: eval $'return\necho bad'
* sh: Fix LINENO and prompt after $'\0 and newline.jilles2014-10-033-0/+9
|
* sh: Remove arbitrary length limit on << EOF markers.jilles2014-09-142-0/+48
| | | | This also simplifies the code.
* sh: Don't hardcode relative paths in the tests stderr files.jilles2014-08-1711-17/+11
| | | | | | | | These paths have had to be adjusted to changes in the testsuite runner several times, so modify the tests to remove the need for such adjustment. A cp in functional_test.sh is now unneeded, but this matters little in performance.
* sh: Mask off shift distance (<< and >>) in arithmetic.jilles2014-08-152-0/+41
| | | | | | | | | | | In C, shift distances equal to or larger than the number of bits in the operand result in undefined behaviour. As part of eliminating undefined behaviour in arithmetic, mask off the distance like Java and JavaScript specify and C on x86 usually does. Assumption: conversion from unsigned to signed retains the two's complement bits. Assumption: uintmax_t has no padding bits.
* Convert bin/sh/tests to ATFngie2014-08-1315-82/+127
| | | | | | | | | | | | | The new code uses a "test discovery mechanism" to determine what tests are available for execution The test shell can be specified via: kyua test -v test_suites.FreeBSD.bin.sh.test_shell=/path/to/test/sh Sponsored by: EMC / Isilon Storage Division Approved by: jmmv (mentor) Reviewed by: jilles (maintainer)
* sh: Allow arbitrarily large numbers in break and continue.jilles2014-07-202-0/+9
| | | | The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
* sh: Correctly handle positional parameters beyond INT_MAX on 64-bit systems.jilles2014-07-122-0/+15
| | | | | | | | | | | | | Currently, there can be no more than INT_MAX positional parameters. Make sure to treat all higher ones as unset to avoid incorrect results and crashes. On 64-bit systems, our atoi() takes the low 32 bits of the strtol() and sign-extends them. On 32-bit systems, the call to atoi() returned INT_MAX for too high values and there is not enough address space for so many positional parameters, so there was no issue.
* sh: Consistently treat ${01} like $1.jilles2014-07-122-0/+5
| | | | | Leading zeroes were ignored when checking whether a positional parameter is set, but not when expanding its value. Ignore leading zeroes in any case.
* sh: Add test for ${01} and ${010} that already works.jilles2014-07-082-0/+5
| | | | | | | | Although it is probably unwise to use this, POSIX is clear that leading zeroes are permitted in positional parameters (and do not indicate octal). Such positional parameters are checked for being unset and/or null correctly, but their value is incorrectly expanded.
* Don't install locale1.0 if MK_NLS == no.jilles2014-07-081-0/+2
| | | | | | | | | | | | The test locale1.0 depends on locale support; it is meaningless without a working LC_MESSAGES. I added an OptionalObsoleteFiles.inc entry. PR: 181151 Submitted by: Garrett Cooper (original version) MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* sh: In getopts, unset OPTARG where POSIX says we should.jilles2014-05-103-0/+14
|
* sh: Add new tests to the Makefile.jilles2014-05-101-0/+2
|
* sh: Don't discard getopts state on unknown option or missing argument.jilles2014-05-102-0/+13
| | | | | | | When getopts finds an invalid option or a missing option-argument, it should not reset its state and should set OPTIND as normal. This is an old ash bug that was fixed long ago in dash. Our behaviour now matches most other shells.
* sh: Send getopts error messages to stderr, not stdout.jilles2014-05-091-1/+1
| | | | Adjust a testcase for this change.
* sh: Add some tests for normal use of getopts.jilles2014-05-074-0/+29
|
OpenPOWER on IntegriCloud