summary refs log tree commit diff
path: root/src/miscbltin.c (follow)
Commit message (Collapse)AuthorAge
* [BUILTIN] Fix trailing field bug in read(1)Herbert Xu2010-09-08
| | | | | | | | | | The new read(1) code fails to handle the last variable correctly if it happens to be terminated by IFS characters. Those characters are included in the last variable but they should not be. This patch fixes this. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [EXPAND] Fix ifsfirst/ifslastp leakHerbert Xu2010-09-08
| | | | | | | | | | | | | | | | 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>
* [BUILTIN] Continue after EINTR in read(1) with no pending signalsHerbert Xu2010-05-29
| | | | | | | | | | | | The recent introduction of SIGCHLD trapping broke read(1) as each SIGCHLD may cause read(1) to return prematurely. Now if we did have a trap for SIGCHLD read(1) should actually do this. However, returning when SIGCHLD isn't trapped is wrong. This patch fixes this by checking for EINTR and pendingsigs in read(1). Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [BUILTIN] Fix off-by-one recordregion in readcmdHerbert Xu2009-11-26
| | | | | | | | | | | | | | | | | | | | | | | Alexey Gladkov <gladkov.alexey@gmail.com> wrote: > > I found another example: > > $ tr -d '[:print:]' < /etc/passwd |tr -d '\t\n' |wc -c > 0 > > $ dash -c 'while read o p; do printf "[%s] [%s]\n" "$o" "$p"; done < > /etc/passwd' |tr -d '[:print:]' |tr -d '[:space:]' |wc -c > 61 > > bug is not fixed yet :( This bug is caused by an off-by-one error in the recordregion call in readcmd. It included the terminating NUL in the region which causes ifsbreakup to include the string after it for scanning. Setting the correct length fixes the problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [BUILTIN] Avoid compiler warnings on isdigitEric Blake2009-08-31
| | | | | | | Pass correct type to ctype macro. Signed-off-by: Eric Blake <ebb9@byu.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [BUILTIN] Fix NUL termination in readcmdHerbert Xu2009-08-31
| | | | | | | | | | | | Commit 55c46b7286f5d9f2d8291158203e2b61d2494420 ([BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd) introduced a bug where sometimes garbage would follow the last field preceding the end-of-line. This was caused by an off-by-one error in the string length calculation. This patch fixes the bug. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmdStefan Potyra2009-08-11
| | | | | | | | | | | | | | | | | | | 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>
* [BUILTIN] Disable ulimit if there is no getrlimitHerbert Xu2005-10-29
| | | | | | | | | | For systems without getrlimit (e.g., klibc) we will disable ulimit. In order to achieve this, builtins.def is now produced by cpp which allows us to use macros such as HAVE_GETRLIMIT in it. Thie also means that we can get rid of the cflags parsing code in mkbuiltins.
* Copyright/licence updates and remove all traces of sys/cdefs.hHerbert Xu2005-10-29
| | | | | | | | | | | 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.
* Renamed error to sh_error.herbert2005-09-26
|
* Initial import.Herbert Xu2005-09-26