summaryrefslogtreecommitdiff
path: root/bin/ksh
AgeCommit message (Collapse)Author
2019-07-24Add #include <stdlib.h> for mkstemp.Brian Callahan
Spotted by maya@netbsd ok deraadt@
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
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.
2019-06-27Some asprintf() calls were checked < 0, rather than the precise == -1.Theo de Raadt
ok millert nicm tb, etc
2019-06-24Fix spellingJeremie Courreges-Anglas
2019-06-24Partial revert of rev. 1.151:Ingo Schwarze
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88, the shell the OpenBSD ksh(1) descends from (via pdksh). The Second Edition (1995) of the book is about ksh93 which we don't provide. Pointed out by Andras Farkas on bugs@.
2019-06-21zap trailing whitespace;Jason McIntyre
2019-06-19Allow string greater/less than than operators to work with test aka [.Todd C. Miller
Previously they were only recognized in [[ ... ]] expressions. This changes sh/ksh to be consistent with test(1) as well as shells like bash and dash. OK jca@ jmc@
2019-05-22mention that using vi command line editing mode requires enabling it;Ingo Schwarze
omission reported by Rudolf Sykora <rsykora at disroot dot org> on misc@; tweak and OK jmc@
2019-04-03Bind ^L (C-l) to clear-screen instead of redrawJeremie Courreges-Anglas
Slightly more useful for some, same defaults as bash. No objection deraadt@ phessler@, ok tb@ kn@ benno@
2019-02-20When evaluating an arithmetical expression, for example inside $(()),Ingo Schwarze
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@
2019-01-25I am retiring my old email address; replace it with my OpenBSD one.Todd C. Miller
2019-01-14Fix three more buglets:Ingo Schwarze
1. Another off-by-one: if a mail file name ends in an (escaped) percent sign, do not forget to check whether the next byte is the percent sign introducing the message (MAILPATH='filename\%%msg'). 2. If the message is empty, use the default message rather than printing a blank line (MAILPATH='filename%'). 3. If the file name is empty, don't bother with mballoc(): the subsequent stat(2) can never succeed. (MAILPATH='%msg'). Found while reviewing the previous commit by tedu@. OK tedu@.
2019-01-14do not peek before the beginning of a stringTed Unangst
ok deraadt schwarze tb
2019-01-07short circuit mail check if MAIL is unset. ok antonTed Unangst
2018-12-30Delete unnecessary <libgen.h> #includesPhilip Guenther
ok deraadt@
2018-12-16Tweak the syntax displays to show that the list of wordsIngo Schwarze
in "for name in [word ...]; do list; done" can be empty. In sh(1), clarify what happens in that case. In ksh(1), clarify how it can happen that the list is never executed. OK jmc@ tb@
2018-12-08Fix kill [-SIGNAME | -s SIGNAME] and simplifyJeremie Courreges-Anglas
While the code intended to support both -s NAME and -s SIGNAME, the tests performed were wrong. Replace convoluted code with less cryptic conditionals. ok anton@
2018-11-30in getopts, when a option is followed by a colon the parameter is mandatorysolene
ok guenther@ deraadt@
2018-11-20Convert the pledge call to idiomatic format 'cause we love grep.Theo de Raadt
2018-11-20Fix the case where the recursion detection isn't reset when the command isMartijn van Duren
interrupted. Lots of back and forth with anton@ OK jca@, tb@, anton@
2018-11-17Use a very regular call pattern to pledge, so that we can continue toTheo de Raadt
grep and compare the use in all programs..
2018-11-16Include "id" in pledge (for setres[ug]id, setgroups) if the shell isNicholas Marriott
privileged and remove it when dropping privileges (set +p), setting a flag to make sure we don't do it again. ok deraadt millert
2018-09-29Export the PWD and OLDPWD shell variables as per POSIX.Todd C. Miller
Previously, these would only be exported if they were present in the environment when the shell started. OK deraadt@ anton@ kn@
2018-09-28Contrary to the sh manual, it is possible to modify the PWD variableTodd C. Miller
(and this is allowed by POSIX). OK deraadt@ kn@
2018-07-09Second attempt of the recently backed out variable expansion fix. This time withanton
a missing NULL check added by jca@ which fixes the segfault in the installer. ok jca@ tb@
2018-07-08Back out previous. naddy and rpe found that it breaks the installer withTheo Buehler
install.sub's ${*:+$*} substitution in addel(). ok jca
2018-07-08Fix a bug related to variable expansion referencing multiple read-onlyanton
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@
2018-06-25Count $MAILCHECK with the monotonic clock.cheloha
So that ksh still looks for new mail every $MAILCHECK seconds, even if the system clock is rolled backward. ok anton@
2018-06-18Use shl_out->fd instead of STDOUT_FILENO in the call the setupterm().Todd C. Miller
Suggested by anton@
2018-06-18Add clear-screen emacs editing command, currently not bound to aTodd C. Miller
key by default. The shell will query the terminfo database to find the escape sequence to clear the screen. OK deraadt@
2018-05-30point readers to the correct place instead of having themSebastian Benoit
jump around. suggested and ok jmc@, ok jcm@
2018-05-18remove the alias type='whence -v' and replace it withSebastian Benoit
a buildin command, that just calls into c_whence(). This makes type look like the buildin in other shells and makes things like system("'type' 'git'"); work. With lots of suggestions and feedback from anton@, kn@ and jca@. ok kn@ jca@
2018-04-24Keep the time pipeline's stack in tactkn
Revision 1.28 (2008) fixed stack abuse by allocating a new one and effectively clearing it. This broke pipelines such as $ time for i in . ; do : ; done /bin/ksh: : is read only Prompted by tb, OK millert, tb, jca
2018-04-13Count $SECONDS with CLOCK_MONOTONIC.cheloha
Keeps $SECONDS advancing uniformly and independent of wall clock jumps. ok jca@
2018-04-09Support 64 bit integers on 32 bit architectures.Tobias Stoeckmann
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
2018-03-31Fix spacing in brace command list grammar.anton
Initial diff by me, later improved by schwarze@; also ok jmc@
2018-03-16improve markup quality in the cases found by the new "--" style messageIngo Schwarze
2018-03-15Favor usage of __func__ in warning/error messages. Some of them referred to theanton
wrong function and fix the rest for consistency. Diff from Michael W. Bombardieri with some cosmetic cleanup applied. ok benno@ tb@
2018-02-06Clarify that the "bind" built-in command only affects Emacs editingIngo Schwarze
mode, to avoid potential confusion pointed out by andreas dot kahari at icm dot uu dot se on misc@. Patch minimally tweaked based on a comment from jmc@. OK anton@ jca@ jmc@ on the previous version without the tweak.
2018-01-20Remove code that has been disabled since 1999. From Michael W. Bombardieri whoanton
also took the time to provide an excellent explanation on why the code isn't useful on tech@. ok jca@
2018-01-16Introduce internal_warningf() and mark internal_errorf() as noreturnJeremie Courreges-Anglas
This helps tools like scan-build, and follows the example of warningf() and errorf(). ok anton@
2018-01-16Stop constructing the ulimit optstring passed to ksh_getopt() at runtime sinceanton
it's rarely subject to change. While here, unifdef RLIMIT_VMEM. ok jca@
2018-01-16One minor scan-build warningJeremie Courreges-Anglas
emacs.c:1041:2: warning: Value stored to 'cp' is never read
2018-01-15Don't try to open HISTFILE if the variable is unset.Jeremie Courreges-Anglas
str_val returns null, not NULL, if the variable isn't set. The erroneous check means that we later tried to open(""). ok millert@ tb@ anton@ benno@
2018-01-15Stop pretending we support building ksh without EDIT/HISTORY supportJeremie Courreges-Anglas
ok anton@
2018-01-14unifdef BRACE_EXPAND; ok jca@anton
2018-01-13remove unused parameter from the static function print_expansions();Ingo Schwarze
patch from Michael W. Bombardieri <mb at ii dot net>; OK tb@
2018-01-12Some more tweaks to NOTESJeremie Courreges-Anglas
- it's safe to assume that there's no plan to write "an `agent' to execute unreadable/setuid/setgid shell scripts" - the BUG-REPORTS file has been removed - update the entry for FPATH, ksh93 also documents the described behavior - kill entry about octal and hex notation in arithmetic expressions (supported) - typos Feedback from Klemens Nanni
2018-01-08update comments that were left behind in the recent unifdef JOB commitSebastian Benoit
from Klemens Nanni, thanks.
2018-01-08Drop two outdated entriesJeremie Courreges-Anglas
Namely POSIX character classes and tilde expansion within parameter substitution. While here, kill a useless line and fix a typo. From Klemens Nanni