| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Sponsored by: EMC / Isilon Storage Division
|
|
|
|
|
| |
The option does not do anything so check that the output of 'set +o' is
different.
|
|
|
|
|
|
|
| |
r295825 erroneously dropped the newline from the input data for 'set -v'
output and multiline history.
Reported by: vangyzen
|
|
|
|
|
| |
This fixes bugs where '\0' was not removed correctly and speeds up the
parser.
|
| |
|
|
|
|
| |
Sponsored by: EMC / Isilon Storage Division
|
|
|
|
|
| |
If a local variable has been made read-only, this should not prevent its
removal when the function returns.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
| |
This was forgotten in r273700.
|
|
|
|
|
| |
Although POSIX leaves things like ${*#X} unspecified, it occasionally occurs
in practice. Add some tests that seem to work sensibly.
|
|
|
|
|
| |
POSIX leaves the result of expanding ${#@} and ${#*} unspecified, but ensure
it is numeric.
|
|
|
|
| |
This was forgotten in r291025.
|
|
|
|
|
| |
"$@" should expand to no words if there are no positional parameters, but
""$@ should always expand to at least an empty word.
|
|
|
|
|
| |
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
| |
Characters escaped with a backslash must be treated as if they were not in
IFS. This includes stripping trailing IFS characters.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
It is likely that $'\uXXXX' and $'\UXXXXXXXX' will allow fewer digits in
future. However, no digits at all should still be disallowed.
|
|
|
|
| |
This was originally broken in r212339 in 2010.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* directly after a $
* directly after ${
* between the characters of a multi-character operator token
* within a parameter name
|
| |
|
|
|
|
|
| |
Example:
eval $'return\necho bad'
|
| |
|
|
|
|
| |
This also simplifies the code.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
| |
The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Leading zeroes were ignored when checking whether a positional parameter is
set, but not when expanding its value. Ignore leading zeroes in any case.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Adjust a testcase for this change.
|
| |
|