summaryrefslogtreecommitdiffstats
path: root/bin/sh/tests
Commit message (Collapse)AuthorAgeFilesLines
* MFC r317912: sh: Fix INTOFF leak after a builtin with different localejilles2017-05-142-0/+6
| | | | | | | | settings. After executing a builtin with different locale settings such as LC_ALL=C true SIGINT handling was left disabled indefinitely.
* MFC r315005: sh: Fix executing wrong command with ${x#$(y)}$(z).jilles2017-03-182-0/+6
| | | | | | | | | | | | | | | | The parsed internal representation of words consists of a byte string with a list of nodes (commands in command substitution). Each unescaped CTLBACKQ or CTLBACKQ | CTLQUOTE byte corresponds to an entry in the list. If param in ${param#%##%%word} is not set, the word is not expanded (in a deviation of POSIX shared with other ash variants and ksh93). Erroneously, the pointer in the list of commands (argbackq) was not advanced. This caused the wrong command to be executed later if the outer word contained another command substitution. Example: echo "${unsetvar#$(echo a)}$(echo b)" wrote "a" but should write "b".
* MFC r314686: sh: Fix crash if a -T trap is taken during command substitutionjilles2017-03-123-0/+14
| | | | | | | | | | | | | | | Code like t=$(stat -f %m "$file") segfaulted if -T was active and a trap was taken while the shell was waiting for the child process to finish. What happened was that the dotrap() call in waitforjob() was hit. This re-entered command execution (including expand.c) at a point not expected by expbackq(), and global state (unallocated stack string and argbackq) was corrupted. To fix this, change expbackq() to prepare for command execution to be re-entered. Reported by: bdrewery
* MFC r314637: sh: Add some already working tests that exercise new code pathsjilles2017-03-124-0/+20
|
* MFC r302937ache2016-08-184-0/+38
| | | | | | Path generation was not according to collate Approved by: jilles
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedngie2016-05-048-474/+449
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division
* MFHgjb2016-04-113-7/+7
|\ | | | | | | Sponsored by: The FreeBSD Foundation
| * sh: Fix some unquoted variables in tests.jilles2016-04-093-7/+7
| | | | | | | | | | The builtins/getopts1.0 test failed if a single-character file existed in the current directory.
* | MFHgjb2016-04-042-0/+11
|\ \ | |/ | | | | Sponsored by: The FreeBSD Foundation
| * sh: Fix use-after-free if a trap replaces itself.jilles2016-03-282-0/+11
| | | | | | | | MFC after: 1 week
* | MFHgjb2016-03-1010-0/+93
|\ \ | |/ | | | | Sponsored by: The FreeBSD Foundation
| * 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.
* | MFHgjb2016-02-243-0/+14
|\ \ | |/ | | | | Sponsored by: The FreeBSD Foundation
| * 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
* | MFHgjb2016-02-224-0/+22
|\ \ | |/ | | | | Sponsored by: The FreeBSD Foundation
| * 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
| |
* | MFHgjb2016-02-181-2/+0
|\ \ | |/ | | | | Sponsored by: The FreeBSD Foundation
| * Test directories can build in parallel fine.bdrewery2016-02-161-2/+0
| | | | | | | | Sponsored by: EMC / Isilon Storage Division
* | Fix build.gjb2016-02-037-7/+0
| | | | | | | | Sponsored by: The FreeBSD Foundation
* | First pass to fix the 'tests' packages.gjb2016-02-028-0/+32
|/ | | | Sponsored by: The FreeBSD Foundation
* 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
|
OpenPOWER on IntegriCloud