summary refs log tree commit diff
path: root/src/eval.c (follow)
Commit message (Collapse)AuthorAge
* [EVAL] Revert SKIPEVAL into EXEXITHerbert Xu2009-08-11
| | | | | | | Now that eval handles EV_TESTED correctly, we can remove the SKIPEVAL hack and simply use EXEXIT for set -e. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [EVAL] Pass EV_TESTED into evalcmdHerbert Xu2009-08-11
| | | | | | | | | | | | | | | | | | This patch fixes the case where the eval command is used with set -e and as part of a construct that should not cause the shell to abort, e.g., as part of the condition of an if statement. This is achieved by propagating the EV_TESTED flag into the evalstring function through evalcmd. As this alters the prototype of evalcmd it is now invoked explicitly by evalbltin. The built-in infrastructure has been changed to accomodate this special case. In order to ensure that the EXIT trap is properly executed this patch clears evalskip in exitshell. This wasn't needed before because of the broken way evalstring worked where it always clears evalskip when called by minusc. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [SIGNAL] Remove EXSIGHerbert Xu2009-02-22
| | | | | | Now that waitcmd no longer uses EXSIG we can remove it. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [BUILD] Fixed build on OS XMark Mentovai2009-01-13
| | | | | | | | | | | | | | | | | | | | Hi, Herbert and friends. I've created a small patch that allows dash to be built on Mac OS X. I'm contributing it here with the hope that it's suitable for inclusion in dash. The changes in this patch are: - __attribute__((__alias__())) is not supported, add an autoconf check - open64 is not present although the stat64 family is, separate the autoconf checks - A syntax error had slipped into a non-glibc codepath - mkbuiltins had a nonportable mktemp invocation for the case where tempfile is not availalble Nothing in this patch is actually Mac OS X-specific, so it might aid portability to other platforms as well. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [EVAL] Fix bad pointer arithmetic in evalcommandSteve Langasek2007-12-23
| | | | | | | | | | | | | | | | dash dies on sparc with a SIGBUS due to an arithmetic error introduced with commit 03b4958, this patch fixes it. --- > Hi Gerrit, > > dash 0.5.4-3 dies on sparc with a SIGBUS due to an arithmetic error > introduced with the patch > 0030-EXEC-Fixed-execing-of-scripts-with-no-hash-bang.diff. The > attached > patch fixes the problem. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* [EXPAND] Removed herefd hackHerbert Xu2007-11-11
| | | | | | | | | | | 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.
* [SHELL] Replace shared illnum message by badnum function.Herbert Xu2007-10-17
| | | | | | This patch adds the badnum function and uses it to mostly replace the use of illnum except in miscbltin where the current code turns out to be smaller because of the twin sh_error calls.
* [EXEC] Fixed execing of scripts with no hash-bangHerbert Xu2007-10-15
| | | | | | | | | | | | | | | | | | | | | | | | | | The function tryexec used the original name instead of the path found through PATH search. This patch fixes that. Test case: trap 'rm -f $TMP' EXIT TMP=$(tempfile -s nosuchthing) cat <<- EOF > $TMP echo OK EOF chmod u+x $TMP cd / PATH=${TMP%/*} ${TMP##*/} Old result: /bin/sh: Can't open filelgY4Fanosuchthing New result: OK
* [EXPAND] Move parse-time quote flag detection to run-timeHerbert Xu2007-09-25
| | | | | | | | | | | | | | | | | | | | 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: <>
* [EVAL] Use dup2 instead of copyfd in evalbackcmdHerbert Xu2007-05-06
| | | | Since we know that dup2 must succeed here we can call it directly.
* [EVAL] Make eval with empty arguments return 0 Herbert Xu2006-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Tue, Jan 10, 2006 at 10:56:23AM +0000, Gerrit Pape wrote: > tags 347232 + patch > quit > > On Mon, Jan 09, 2006 at 04:29:19PM +0100, Marco Nenciarini wrote: > > The problem is here: > > > > # Set the kernel 2.6 option only for fresh install > > test -z "$(GetMenuOpt "kopt" "")" && kopt_2_6="root=$root_device_2_6 ro" > > > > # Extract options for specific kernels > > eval $(ExtractMenuOpts "\(kopt_[a-zA-Z0-9_]\+\)") > > > > If the first test fails and the eval argument is empty then dash > > terminate with exitcode 1. > > > This is a simple testcase: > > tm:~# bash -c "set -e ;/bin/false && : ; eval ''; echo 'END'"; echo $? > > END > > 0 > > tm:~# dash -c "set -e ;/bin/false && : ; eval ''; echo 'END'"; echo $? > > 1 > > > > if you insert any command with successfull exit status before the > > empty eval, all work ok: > > tm:~# bash -c "set -e ;/bin/false && : ; : ; eval ''; echo 'END'"; echo $? > > END > > 0 > > tm:~# dash -c "set -e ;/bin/false && : ; : ; eval ''; echo 'END'"; echo $? > > END > > 0 > > Yes, I can confirm this is a bug in dash. The standard says > > EXIT STATUS > > If there are no arguments, or only null arguments, eval shall > return a zero exit status; otherwise, it shall return the exit > status of the command defined by the string of concatenated > arguments separated by <space>s. > > Hi Herbert, please see http://bugs.debian.org/347232 Changed evalstring to return the exit status instead of evalskip. This allows us to return zero if the string is empty.
* 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.
* Added eflag fixes for trap and minusc.herbert2005-09-26
| | | | | | Let evaltree handle traps from cmdloop. Reset evalskip after minusc is executed. Stop executing traps once SKIPEVAL is seen.
* Removed unnecessary inclusion of main.h from eval.c.herbert2005-09-26
|
* Turn evalskip into a bit field.herbert2005-09-26
| | | | This allows SKIPEVAL and SKIPFUNC to coexist which is needed for eval return 1.
* Renamed error to sh_error.herbert2005-09-26
|
* Only set skipcount for break and continue.herbert2005-09-26
|
* Update funcnest atomically.herbert2005-09-26
|
* Replaced EXEVAL with SKIPEVAL.herbert2005-09-26
|
* Do not clobber exit status on EXEVAL.herbert2005-09-26
|
* Catch set -e exits within built-in commands.herbert2005-09-26
|
* Initial import.Herbert Xu2005-09-26