| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Here's another bug bisecting to f42e443bb ([EXPAND] Fix
ifsfirst/ifslastp leak, 2010-09-08). It was found with the following
test case, based on the configure script for Tracker:
dash -x -c '
<<-_ACEOF
$@
_ACEOF
exec
' - abcdefgh
+
+ exec �a
exec: 1: : Permission denied
The missing ifsfree call is in expandarg when it returns to openhere
during here document expansion.
Reported-by: Aurelien Jarno <aurel32@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Solaris lacks paths.h and the various _PATH_* #defines.
Check for them in configure.ac and fall back on the
usual suspects when they are missing.
- Older Solaris lacks isblank(), and versions that have it
use a macro. Check for the declaration in configure.ac
and fall back on a naive version when missing.
- Older Solaris does not support %jd (intmax_t) in format
strings, but it does support the PRIdMAX macro from inttypes.h.
Do a configure check for PRIdMAX and use it in the code.
If it doesn't exist, define it to "lld" when sizeof(long long)
equals sizeof(intmax_t) as this is more likely to work on
older systems. Otherwise, use "jd" and hope for the best.
- Older Solaris lacks stdint.h, but inttypes.h provides the
same types and works on all platforms I've tried dash on,
so just use it instead.
- Older Solaris doesn't like it when vsnprintf() is passed
a NULL buffer (in violation of the POSIX spec, of course).
Pass a 1-byte dummy buffer instead.
- Solaris lacks tempfile and mktemp programs. Fall back on a
"good-enough" custom function in mkbuiltins.
Signed-off-by: Brian Koropoff <bkoropoff@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new read(1) implementation incorrectly assumes that ifsbreakup
ignores characters escaped by CTLESC. As such it fails to handle
backslashes except for escaping newlines.
This patch makes it use recordregion for every part that isn't
escaped by a backslash.
Reported-by: Jilles Tjoelker <jilles@stack.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A tilde expansion generates a valid pathname. Splitting it using IFS
either leaves it unchanged or changes it to something unintended.
This fixes FreeBSD sh test expansion/tilde1.0 and does not change the
outcome of the other tests.
This fixes Debian bug #601096.
Example:
IFS=m HOME=/tmp; printf "%s\n" ~
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The commit f42e443bb511ed3224f09b4fcf0772438ebdbbfa
[EXPAND] Fix ifsfirst/ifslastp leak
revealed yet another ifsfirst/ifslastp leak in casematch.
Previously it was hidden because ifsfirst/ifslastp was cleared
unconditionally on entry (which caused the leakage of those
entries).
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As it stands expandarg may return with a non-NULL ifslastp which
then confuses any subsequent ifsbreakup user that doesn't clear
it directly.
What's worse, if we get interrupted before we hit ifsfree in
expandarg we will leak memory.
This patch fixes this by always calling ifsfree in expandarg
thus ensuring that ifslastp is always NULL on the normal path.
It also adds an ifsfree call to the RESET path to ensure that
memory isn't leaked.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In other ash variants, a partial implementation of ksh-like cmd >file*
adds and removes CTLESC bytes ('\x81') in redirection filenames,
preserving 8-bit transparency. Long ago, dash removed the code to add
the CTLESC bytes, but not the code to remove them, causing corruption of
filenames containing CTLESC. This commit removes the code to remove the
CTLESC bytes.
The CTLESC byte occurs frequently in UTF-8 encoded non-Latin text.
This bug has been reported various times to Ubuntu and Debian (e.g.
Launchpad Ubuntu #422298). This patch is the same as the one submitted
by Alexander Korolkov in Ubuntu #422298.
Signed-off-by: Jilles Tjoelker <jilles@stack.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When I try to split fields by tabs, dash doesn't honour multiple tabs
between fields as whitespace (at least that's how I interpret [1],
please correct me if I'm wrong).
#!/bin/sh
# "1\t2\t\t3"
TESTSTRING="1 2 3"
# only "\t"
IFS=" "
echo "$TESTSTRING" | while read p1 p2 p3; do
echo "p1=${p1}, p2=${p2}, p3=${p3}"
done
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The change
[EXPAND] Do not quote back slashes in parameter expansions outside quotes
broke quote removal after parameter expansion. This is because
its effecte extended beyond that of quoted patterns.
This patch fixes this by limiting the change to just quoted
patterns.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Back in January an attempt was made to fix the interpretation of
quoted slashes in expmeta. However, this only fixed those cases
where the quoted slash is at the front of the word. The case of
non-leading slashes caused the previous directory part to gain a
back slash suffix which causes subsequent pattern matches to fail.
This patch fixes this by removing the back slash in that case.
Thanks to Romain Tartière fox reporting this bug.
Test case:
echo /*"/null"
Old result:
/*/null
New result:
/dev/null
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
| |
klibc does not have mempcpy, so system.h must be included where this is used
to provide the replacement. glob.h doesn't exist, so we need to guard this
include with the HAVE_GLOB definition. Finally, klcc didn't like the syntax
of the main definition in mksignames, and the resulting program segfaulted
when trying to dereference any part of the argv array. Updating the main
function definition solved the problem.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The change
[EXPAND] Do not quote back slashes in parameter expansions outside quotes
triggered a latent bug in expmeta where the forward slashes when preceded
by a blackslash weren't recognised as directory separators. This was hidden
because a work-around was put in place for glob(3) which meant that we never
had any backslashes immediately before forward slashes.
This patch fixes the metaflag loop to recognise forward slashes even when
they follow a backslash.
Thanks to Daniel Hahler for reporting this problem.
Test case:
echo "/"root*
Old result:
/root*
New result:
/root
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we always expanded here-documents in a subshell. This is
contrary to the POSIX specification and how other shells behave. What's
more this slows down many expansions due to the extra fork (however, it
must be said that it is possible for it speed up certain expansions by
running it simultaneously with the command on two CPUs).
This patch move the expansion into the current shell environment.
Test case:
unset a
cat <<- EOF > /dev/null
${a=NOT}
EOF
echo ${a}BAD
Old result:
BAD
New result:
NOTBAD
|
|
|
|
|
|
|
|
|
|
|
| |
The herefd hack goes back more than a decade. it limits the amount of
memory we have to allocate when expanding here-documents by writing the
result out from time to time. However, it's no longer safe because the
stack is used to place intermediate results too and there we certainly
don't want to write them out should we be short on memory.
In any case, with today's computers we can afford to keep the entire
result in memory and write them out at the end.
|
|
|
|
|
|
|
|
| |
Debian's libc6 as of 2.6.1-6 has working glob(3)/fnmatch(3) support.
This patch adds the options --enable-glob and --enable-fnmatch to
the configure script. By default glob(3) and fnmatch(3) are still
unused. However, on distros where the glibc is known to work you
may enable these options.
|
|
|
|
| |
The case where the expansion isn't quoted is the norm.
|
|
|
|
|
| |
This patch adds assignment operator support in arithmetic expansions. It
also changes the type used to intmax_t.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Wed, Apr 11, 2007 at 01:24:21PM -0700, Micah Cowan wrote:
> Package: dash
> Version: 0.5.3-3
>
> Bug first reported against Ubuntu at
> https://bugs.launchpad.net/ubuntu/+source/dash/+bug/105634
> by Paul Smith
>
> The description and some comments from that bug report follow.
>
> -----
>
> This operation fails on Ubuntu:
>
> $ /bin/sh -c 'if false; then d="${foo/bar}"; fi'
> /bin/sh: Syntax error: Bad substitution
>
> When used with other POSIX shells it succeeds. While semantically the
> variable reference ${foo/bar} is not valid, this is not a syntax error
> according to POSIX, and since the variable assignment expression is
> never invoked (because it's within an "if false") it should not be seen
> as an error.
>
> I ran into this because after restarting my system I could no longer log
> in. It turns out that the problem was (a) I had edited .gnomerc to
> source my .bashrc file so that my environment would be set properly, and
> (b) I had added some new code to my .bashrc WITHIN A CHECK FOR BASH!
> that used bash's ${var/match/sub} feature. Even though this code was
> within a "case $BASH_VERSION; in *[0-9]*) ... esac (so dash would never
> execute it since that variable is not set), it still caused dash to
> throw up.
>
> -----
>
> FYI, some relevant details from POSIX:
>
> Section 2.3, Token Recognition:
>
> 5. If the current character is an unquoted '$' or '`', the shell shall
> identify the start of any candidates for parameter expansion ( Parameter
> Expansion), command substitution ( Command Substitution), or arithmetic
> expansion ( Arithmetic Expansion) from their introductory unquoted
> character sequences: '$' or "${", "$(" or '`', and "$((", respectively.
> The shell shall read sufficient input to determine the end of the unit
> to be expanded (as explained in the cited sections).
>
> Section 2.6.2, Parameter Expansion:
>
> The format for parameter expansion is as follows:
>
> ${expression}
>
> where expression consists of all characters until the matching '}'. Any
> '}' escaped by a backslash or within a quoted string, and characters in
> embedded arithmetic expansions, command substitutions, and variable
> expansions, shall not be examined in determining the matching '}'.
>
> [...]
>
> The parameter name or symbol can be enclosed in braces, which are
> optional except for positional parameters with more than one digit or
> when parameter is followed by a character that could be interpreted as
> part of the name. The matching closing brace shall be determined by
> counting brace levels, skipping over enclosed quoted strings, and
> command substitutions.
>
> ---
>
> In addition to bash I've checked Solaris /bin/sh and ksh and they don't
> report an error.
>
> -----
> Micah Cowan:
>
> The applicable portion of POSIX is in XCU 2.10.1:
>
> "The WORD tokens shall have the word expansion rules applied to them
> immediately before the associated command is executed, not at the time
> the command is parsed."
>
> This seems fairly clear to me.
This patch moves the error detection to expansion time.
Test case:
if false; then
echo ${a!7}
fi
echo OK
Old result:
dash: Syntax error: Bad substitution
New result:
OK
|
|
|
|
|
|
|
|
| |
This patch gets rid of the stack mark tracking hack by allocating a little
bit of stack memory if we're at risk of planting a stack mark which may be
grown later. To do this a new function pushstackmark is added which lets
the user pick a bigger amount to allocate since some users do that anyway
after setting a stack mark.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
dash-0.5.3 has an issue reading some line lengths [1].
This is reproducable on amd64, but not on other arches for some reason.
$ cat bug.sh
(read line; echo "${line%%=*}") <<EOF
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
EOF
printf "\
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
" | (read line; echo "${line%%=*}")
$ bash bug.sh
TITLE
TITLE
$ dash bug.sh
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TITLE
Attahced is a patch to fix the issue
Thanks
Roy
[1] http://bugs.gentoo.org/show_bug.cgi?id=180680
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Because the parser does not recursively parse parameter expansion with respect
to quotes, we can't accurately determine quote status at parse time. This
patch works around this by moving the quote detection to run-time where we
do interpret it recursively.
Test case:
foo=\\
echo "<${foo#[\\]}>"
Old result:
<\>
New result:
<>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously code was added so that tilde expansion was carried out
parameter expansions within double quotes. This change was made
with reference the behaviour of bash at the time. Bash has since
be fixed so that this behaviour no longer occurs which is in line
with most other POSIX shells.
So this patch removes that behaviour in dash as well.
Test case:
unset a
echo "${a:-~root}"
Old result:
/root
New result:
~root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously tilde expansion was not carried out for =?#% expansion words.
This is contrary to the POSIX specification.
Test case:
a=~root:~root
echo ${a#~root}
Old result:
/root:/root
New result:
:/root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Test case:
a=/b/c/*
b=\\
echo ${a%$b*}
Old result:
/b/c/*
New result:
/b/c/
|
|
|
|
|
|
|
|
| |
The return value of ccmatch was being treated as 0 or 1 but
it's actually zero or non-zero. This broke inverted character
class matching.
Reported by Alexander Skwar.
|
|
|
|
|
|
|
|
|
| |
The existing scheme of using the native char for syntax array indicies
makes cross-compiling difficult. Therefore it makes sense to choose
one specific sign for everyone.
Since signed chars are native to most platforms and i386, it makes more
sense to use that if we are to choose one type for everyone.
|
|
|
|
| |
All users of mempcpy must include system.h.
|
|
|
|
|
|
|
|
| |
Removed obsolete extern declaration on funcnest. This conflits with the
correct static definition.
Changed memtodest prototype to use char * instead of unsigned char *.
Perform the unsigned char cast inside memtodest instead.
|
|
|
|
|
| |
klibc doesn't have and doesn't need getpwnam. This change creates
getpwhome which always returns NULL if getpwnam doesn't exist.
|
|
|
|
|
|
|
|
|
|
|
| |
This change updates the BSD licence to the three-clause version since
NetBSD has already done so. This makes dash GPL-compatible.
It also adds Christos Zoulas (NetBSD ash maintainer) to the COPYING file.
I've added "copyright by Herbert Xu" to most files.
Finally all CVS IDs and inclusion of sys/cdefs.h have been removed.
The latter is needed for support of klibc.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|