summary refs log tree commit diff
path: root/src/miscbltin.c (follow)
Commit message (Collapse)AuthorAge
* [SHELL] Port to SolarisBrian Koropoff2011-03-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* [BUILTIN] Fix backslash handling in read(1)Herbert Xu2011-03-11
| | | | | | | | | | | | 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>
* [BUILTIN] Fix CTLESC clobbering by read(1)Herbert Xu2011-03-10
| | | | | | | | | | | | | The changeset 55c46b7286f5d9f2d8291158203e2b61d2494420 [BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd uses CTLESC to prevent field splitting in read(1). However, it did not escape CTLESC itself in the input stream. This patch adds the necessary CTLESC characters so that CTLESC isn't corrupted. Reported-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [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