summaryrefslogtreecommitdiffstats
path: root/bin/ksh/eval.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-281-3/+3
| | | | | | value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
* When evaluating an arithmetical expression, for example inside $(()),schwarze2019-02-201-1/+4
| | | | | | | | | | | | | | | | | | | never do substitution (neither parameter, nor command, nor arithmetic, nor tilde substitution) on the values of any variables encountered inside the expression, but do recursively perform arithmetical evaluation of subexpressions as required. This makes behaviour more consistent, without hindering any behaviour promised in the manual page. A quirk originally reported by Andy Chu <andychup at gmail dot com> was that in the past, when encountering an array index, the shell would not only do evaluation, but also substitution on the array index, even though substitution would not be done on the expression in general. tobias@ contributed to initial efforts of understanding the quirk. patch tested in a bulk build by naddy@ "please commit" deraadt@
* Second attempt of the recently backed out variable expansion fix. This time withanton2018-07-091-4/+35
| | | | | | a missing NULL check added by jca@ which fixes the segfault in the installer. ok jca@ tb@
* Back out previous. naddy and rpe found that it breaks the installer withtb2018-07-081-35/+4
| | | | | | install.sub's ${*:+$*} substitution in addel(). ok jca
* Fix a bug related to variable expansion referencing multiple read-onlyanton2018-07-081-4/+35
| | | | | | | | | | | variables; such as positional arguments. Since global() returns a pointer to static storage for read-only variables, the memory pointed to needs to be copied to prevent any subsequent call to global() to override the previously accessed variable. Bug reported by Andreas Kusalananda Kähäri on bugs@ ok benno@ jca@ tb@
* Support 64 bit integers on 32 bit architectures.tobias2018-04-091-2/+2
| | | | | | | No binary change on amd64 and there should be no differences on any other 64 bit architecture either (because long = int64_t). ok cheloha, tb
* Introduce internal_warningf() and mark internal_errorf() as noreturnjca2018-01-161-4/+4
| | | | | This helps tools like scan-build, and follows the example of warningf() and errorf(). ok anton@
* unifdef BRACE_EXPAND; ok jca@anton2018-01-141-13/+2
|
* Bring back the sign compare changes, this time with a fix from otto@millert2018-01-061-5/+6
| | | | that fixes the issues seen on hppa. OK deraadt@ otto@
* Back out sign compare changes that appear to cause problems on hppa.millert2018-01-041-6/+5
| | | | Requested by deraadt@
* Add WARNINGS=yes to ksh and fix the resulting sign compare warnings.millert2018-01-011-5/+6
| | | | OK tb@
* Remove unused copy_non_glob() in ksh.nayden2017-08-271-43/+1
| | | | | Report and diff by David Crosby <dave@dafyddcrosby.com> OK otto@
* Backout previous due to a bug discovered by zhuk@ that requires some tinkeringanton2017-07-041-139/+3
| | | | and is not an easy fix for now.
* Add support for pattern substitution to variables in ksh using a common syntaxanton2017-07-041-3/+139
| | | | | | borrowed from ksh93. Survived a ports build performed by naddy@ and encouraged by many.
* Quiet an "implicit conversion from 'int' to 'char' changes value"millert2017-05-011-2/+2
| | | | warning from clang.
* POSIX-compliant behavior of "set -u" regarding "$*" and "$@" specialsczarkoff2016-03-051-4/+4
| | | | | | All work done by Martijn Dekker OK millert@
* rename global "e" to genv to avoid accidental shadowing and aliasing.tedu2015-12-301-4/+4
| | | | ok millert nicm tb
* Move system headers from sh.h to those files that actually need them.tb2015-12-141-1/+4
| | | | ok mmcc@ a while ago
* Use isdigit() instead of ksh's homebrewed alternative.mmcc2015-11-121-1/+2
| | | | ok nicm@. Also discussed with millert@ and guenther@.
* Remove the define NOT, replace it with '!'. No binary change.mmcc2015-10-191-3/+3
| | | | | | | | "The ^ is used in regular expressions and many versions of fnmatch(3) accept both ! and ^. However, we are never going to accept ^ instead of ! so I think this makes sense" -millert@ "go for it" -nicm@
* Move string.h include from sh.h to the files that use it.mmcc2015-10-191-1/+2
| | | | ok nicm@
* Apply style(9) to header includes.mmcc2015-10-191-4/+6
| | | | ok nicm@
* Last of the (thing *)0 -> NULL, from Michael McConville. No binarynicm2015-09-181-5/+5
| | | | change.
* Remove unnecessary casts, from Michael McConville. No binary change.nicm2015-09-171-4/+4
|
* correct spelling of NULL from (char *)0. from Michael McConville.tedu2015-09-151-5/+5
| | | | ok md5
* Back out revision 1.38. Commands executed via `foo` or $( bar )millert2013-09-141-10/+2
| | | | | actually should inherit "set -e" status according to POSIX. OK jca@
* Make $(< /nonexistent) have the same behaviour as $(cat /nonexistent)jca2013-07-011-4/+10
| | | | | | wrt. errors (do not unwind and do not treat this as fatal if set -e is used). This matches what bash does. Tweak regress tests while here. ok millert@, jasper@ agrees
* Commands executed via `foo` or $( bar ) should not inherit "set -e"millert2013-06-191-2/+10
| | | | | | status. We can't use XERROK for this (since the command might set -e itself) so just save & restore the value of FERREXIT for the comsub() call to execute(). OK jca@
* gc unused var; from Michael W. Bombardieriotto2011-10-111-5/+2
|
* fix uninitialized variable warnings (lifted from mksh).okan2011-03-151-3/+6
| | | | noticed by and ok kevlo@
* fix the cases where ${name#pat} and ${name%pat} will generate an empty wordfgsch2010-03-241-2/+5
| | | | | | when they shouldn't. originally from mksh but modified to handle the case when the expr is quoted as noticed by halex@. input from guenther@ and halex@, millert@ ok
* pass "xerrok" status across the execution call stack to more closelyjaredy2009-01-291-2/+2
| | | | | | | | | | | | | | | | match what both POSIX and ksh.1 already describe in regards to set -e/errexit's behavior in determining when to exit from nonzero return values. specifically, the truth values tested as operands to `&&' and `||', as well as the resulting compound expression itself, along with the truth value resulting from a negated command (i.e. a pipeline prefixed `!'), should not make the shell exit when -e is in effect. issue reported by matthieu. testing matthieu, naddy. ok miod (earlier version), otto. man page ok jmc.
* backout last change; iff is right.fgsch2007-08-021-2/+2
| | | | prompted by deraadt@
* while i'm here: iff -> iffgsch2007-08-021-2/+2
|
* fix memory leaks and one potential null deref found by coverity. from netbsd.fgsch2007-08-021-1/+2
| | | | millert@ ok
* fix lint comments, no functional changes; ok rayjaredy2006-04-101-2/+2
|
* Simplify savefd() by removing the "noclose" flag and make noclosemillert2006-03-171-2/+2
| | | | | behavior the default. Almost all uses of savefd() are followed by an implicit or explicit close. OK otto@
* fix a few name clashes with libc; found by lint. ok deraadt@otto2005-12-111-2/+2
|
* lots of indentation cleanup, now ksh is readable like our other code.deraadt2005-03-301-111/+100
| | | | double checked to make sure no binaries change, and eyed by niallo
* knfderaadt2005-02-251-1/+2
|
* Introduce POSIX hex and octal (0x... and 0...) constants in arithmeticotto2005-02-021-2/+2
| | | | | | | expressions. Work by Matthias Kilian, based on an old diff by myself. Note: MAKEDEV should be updated. Tested by many, thanks. ok millert@ deraadt@
* Fix previous commit here, I add the case statement to the wrong switch.millert2004-12-221-2/+2
|
* Make 'echo ${a[@]:?foo}' produce an error, not a core dump.millert2004-12-221-1/+2
| | | | Bug noticed by otto@.
* Use stdbool.h instead of rolling our own bools.millert2004-12-221-7/+7
|
* Ansification plus some minor knf. No binary change on i386 andotto2004-12-201-78/+35
| | | | | sparc64, binary change in lex.o on macppc due to introduction of dopprompt() prototype. ok millert@
* deregistermillert2004-12-181-18/+18
|
* Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.millert2004-12-181-59/+32
| | | | First step in making the ksh code easier to read. From Matthias Kilian
* Restore sp before calling snptreef() so the error message containsmillert2004-12-131-3/+3
| | | | the actual expression that caused the error. OK otto@
* partially backout prevous commit, it breaks eval of ${a[@]}otto2004-12-091-2/+1
|
* Fix core dumps for ${@:?word} and ${foo[@]?bar}. With help frommillert2004-12-081-1/+3
| | | | and OK otto@. Closes PR 4023.