Branch :
| Author | Commit | Date | CI | Message |
|---|---|---|---|---|
| 0db84b27 | 2020-07-22 19:20:41 | Collapse consecutive stars to avoid exponential behavior. OK tb@ | ||
| cbb0b321 | 2020-07-07 10:33:58 | Add support for set -o pipefail With the pipefail option set, the exit status of a pipeline is 0 if all commands succeed, or the return status of the rightmost command that fails. This can help stronger error checking, but is not a silver bullet. For example, commands will exhibit a non-zero exit status if they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was considered useful enough to be included in the next POSIX standard. This implementation remembers the value of the pipefail option when a pipeline is started, as described as option 1) in https://www.austingroupbugs.net/view.php?id=789#c4102 Requested by ajacoutot@, ok millert@ | ||
| e5c8b1cb | 2020-05-22 07:50:07 | Fix the exit code when eval()uating a || compound list, it would terminate the shell when running under -e. See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=269067 and Bug reported including fix by Leah Neukirchen, Thanks! ok millert@ | ||
| 28297e90 | 2020-05-08 14:30:42 | Use proper function pointer type instead of void * Mixing up function and void pointers isn't defined by POSIX or the C standard. POSIX only specifies that casting the result of dlsym(3) to an appropriate function pointer works. Avoid all this by using a typedef. from Michael Forney, ok tb@ | ||
| 96c62c75 | 2020-02-21 18:21:23 | Enforce that TMOUT is an integer literal to prevent command execution from the environment at shell initialization time. During startup, ksh calls 'eval typeset -i TMOUT="${TMOUT:-0}"'. which allows command injection via arithmetic expansion, e.g., by setting TMOUT to 'x[`/bin/echo Hi >&2`]'. Problem noted by Andras Farkas and tj, inspired by a similar issue in AT&T's ksh. Tested in snaps for two weeks. "go for it" deraadt | ||
| c6b77f58 | 2019-11-26 22:49:01 | some corrections to CDPATH; from chohag | ||
| fbcfde02 | 2019-10-27 15:02:19 | No need for <sys/uio.h> as writev(2) isn't used any more. | ||
| 79ad3eb6 | 2019-10-27 14:58:52 | Don't fail hard if we can't preallocate history storage. Using alloc.c for the history array brings no value and prevents easy handling of memory shortage. Switch to plain reallocarray and keep running if HISTSIZE is too big. The allocation is still done upfront with no sanity checking, it would probably be nicer to allocate space as needed. Issue reported by thomas@habets.se who suggested a different approach. | ||
| c6479af2 | 2019-07-24 14:33:16 | Add #include <stdlib.h> for mkstemp. Spotted by maya@netbsd ok deraadt@ | ||
| 3aaa63eb | 2019-06-28 13:34:58 | When system calls indicate an error they return -1, not some arbitrary 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. | ||
| 95af8abf | 2019-06-27 18:03:36 | Some asprintf() calls were checked < 0, rather than the precise == -1. ok millert nicm tb, etc | ||
| c3663e2f | 2019-06-24 15:05:17 | Fix spelling | ||
| adf61961 | 2019-06-24 14:22:39 | Partial revert of rev. 1.151: 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@. | ||
| 25a61275 | 2019-06-21 10:49:17 | zap trailing whitespace; | ||
| 5b199efb | 2019-06-19 18:18:22 | Allow string greater/less than than operators to work with test aka [. 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@ | ||
| 28f5859d | 2019-05-22 15:23:23 | mention that using vi command line editing mode requires enabling it; omission reported by Rudolf Sykora <rsykora at disroot dot org> on misc@; tweak and OK jmc@ | ||
| 1c8c58f6 | 2019-04-03 14:55:12 | Bind ^L (C-l) to clear-screen instead of redraw Slightly more useful for some, same defaults as bash. No objection deraadt@ phessler@, ok tb@ kn@ benno@ | ||
| 0ac57757 | 2019-02-20 23:59:17 | When evaluating an arithmetical expression, for example inside $(()), 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@ | ||
| bf198cc6 | 2019-01-25 00:19:25 | I am retiring my old email address; replace it with my OpenBSD one. | ||
| da79231e | 2019-01-14 08:48:16 | Fix three more buglets: 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@. | ||
| 0dd2a5d5 | 2019-01-14 00:59:19 | do not peek before the beginning of a string ok deraadt schwarze tb | ||
| b582ba36 | 2019-01-07 20:50:43 | short circuit mail check if MAIL is unset. ok anton | ||
| ef80df5c | 2018-12-30 23:09:58 | Delete unnecessary <libgen.h> #includes ok deraadt@ | ||
| 7a804a67 | 2018-12-16 13:08:35 | Tweak the syntax displays to show that the list of words 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@ | ||
| 3173a78d | 2018-12-08 21:03:51 | Fix kill [-SIGNAME | -s SIGNAME] and simplify 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@ | ||
| d93678d7 | 2018-11-30 08:55:57 | in getopts, when a option is followed by a colon the parameter is mandatory ok guenther@ deraadt@ | ||
| f56dcaa1 | 2018-11-20 08:12:26 | Convert the pledge call to idiomatic format 'cause we love grep. | ||
| c722fcad | 2018-11-20 07:02:23 | Fix the case where the recursion detection isn't reset when the command is interrupted. Lots of back and forth with anton@ OK jca@, tb@, anton@ | ||
| 781a00ff | 2018-11-17 18:14:58 | Use a very regular call pattern to pledge, so that we can continue to grep and compare the use in all programs.. | ||
| 0995ade0 | 2018-11-16 06:41:58 | Include "id" in pledge (for setres[ug]id, setgroups) if the shell is privileged and remove it when dropping privileges (set +p), setting a flag to make sure we don't do it again. ok deraadt millert | ||
| 3da59482 | 2018-09-29 14:13:19 | Export the PWD and OLDPWD shell variables as per POSIX. Previously, these would only be exported if they were present in the environment when the shell started. OK deraadt@ anton@ kn@ | ||
| c2dc00b0 | 2018-09-28 18:32:39 | Contrary to the sh manual, it is possible to modify the PWD variable (and this is allowed by POSIX). OK deraadt@ kn@ | ||
| 42df5cbd | 2018-07-09 00:20:35 | Second attempt of the recently backed out variable expansion fix. This time with a missing NULL check added by jca@ which fixes the segfault in the installer. ok jca@ tb@ | ||
| ab0ce7ee | 2018-07-08 17:52:48 | Back out previous. naddy and rpe found that it breaks the installer with install.sub's ${*:+$*} substitution in addel(). ok jca | ||
| 24304e34 | 2018-07-08 13:18:44 | Fix a bug related to variable expansion referencing multiple read-only 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@ | ||
| 36de39ea | 2018-06-25 15:22:30 | Count $MAILCHECK with the monotonic clock. So that ksh still looks for new mail every $MAILCHECK seconds, even if the system clock is rolled backward. ok anton@ | ||
| caad3202 | 2018-06-18 21:46:05 | Use shl_out->fd instead of STDOUT_FILENO in the call the setupterm(). Suggested by anton@ | ||
| a3c80d85 | 2018-06-18 17:03:58 | Add clear-screen emacs editing command, currently not bound to a key by default. The shell will query the terminfo database to find the escape sequence to clear the screen. OK deraadt@ | ||
| d6946675 | 2018-05-30 21:20:52 | point readers to the correct place instead of having them jump around. suggested and ok jmc@, ok jcm@ | ||
| b4fe65e7 | 2018-05-18 13:25:20 | remove the alias type='whence -v' and replace it with 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@ | ||
| 837faf05 | 2018-04-24 08:25:16 | Keep the time pipeline's stack in tact 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 | ||
| 38b7fdc0 | 2018-04-13 18:18:36 | Count $SECONDS with CLOCK_MONOTONIC. Keeps $SECONDS advancing uniformly and independent of wall clock jumps. ok jca@ | ||
| 517d3880 | 2018-04-09 17:53:36 | Support 64 bit integers on 32 bit architectures. 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 | ||
| e5b600b9 | 2018-03-31 14:58:19 | Fix spacing in brace command list grammar. Initial diff by me, later improved by schwarze@; also ok jmc@ | ||
| 519cd48e | 2018-03-16 16:58:26 | improve markup quality in the cases found by the new "--" style message | ||
| 97445c82 | 2018-03-15 16:51:29 | Favor usage of __func__ in warning/error messages. Some of them referred to the wrong function and fix the rest for consistency. Diff from Michael W. Bombardieri with some cosmetic cleanup applied. ok benno@ tb@ | ||
| 6965dcf2 | 2018-02-06 15:13:32 | Clarify that the "bind" built-in command only affects Emacs editing 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. | ||
| 81a95e3f | 2018-01-20 15:32:20 | Remove code that has been disabled since 1999. From Michael W. Bombardieri who also took the time to provide an excellent explanation on why the code isn't useful on tech@. ok jca@ | ||
| 6c72b531 | 2018-01-16 22:52:32 | Introduce internal_warningf() and mark internal_errorf() as noreturn This helps tools like scan-build, and follows the example of warningf() and errorf(). ok anton@ | ||
| 2bd0d27d | 2018-01-16 20:40:43 | Stop constructing the ulimit optstring passed to ksh_getopt() at runtime since it's rarely subject to change. While here, unifdef RLIMIT_VMEM. ok jca@ | ||
| 565b7249 | 2018-01-16 17:17:18 | One minor scan-build warning emacs.c:1041:2: warning: Value stored to 'cp' is never read | ||
| e2f403d1 | 2018-01-15 22:30:38 | Don't try to open HISTFILE if the variable is unset. 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@ | ||
| 3dc0c5b1 | 2018-01-15 14:58:05 | Stop pretending we support building ksh without EDIT/HISTORY support ok anton@ | ||
| 9a36d1f0 | 2018-01-14 16:04:21 | unifdef BRACE_EXPAND; ok jca@ | ||
| b43024c2 | 2018-01-13 02:06:54 | remove unused parameter from the static function print_expansions(); patch from Michael W. Bombardieri <mb at ii dot net>; OK tb@ | ||
| 10224b2f | 2018-01-12 14:20:57 | Some more tweaks to NOTES - 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 | ||
| 83457235 | 2018-01-08 22:22:28 | update comments that were left behind in the recent unifdef JOB commit from Klemens Nanni, thanks. | ||
| 00c69fa2 | 2018-01-08 13:39:06 | Drop two outdated entries Namely POSIX character classes and tilde expansion within parameter substitution. While here, kill a useless line and fix a typo. From Klemens Nanni | ||
| 035c6fec | 2018-01-08 13:01:31 | Remove unused "args" param from kb_add(), it is always NULL. OK anton@ jca@ | ||
| 8bb10327 | 2018-01-08 12:08:17 | Kill entries that are obviously outdated/out of scope Pointed out by Klemens Nanni who had ~ the same diff | ||
| 8234bcc5 | 2018-01-07 19:18:56 | Add proper bounds checking to kb_add(). OK anton@ | ||
| 4c503bcd | 2018-01-06 16:28:58 | Bring back the sign compare changes, this time with a fix from otto@ that fixes the issues seen on hppa. OK deraadt@ otto@ | ||
| c9653cd6 | 2018-01-05 15:44:31 | unifdef JOBS support Prompted by a mail from Klemens Nanni, who also had the same diff. ok deraadt@ millert@ | ||
| 6d67984d | 2018-01-05 13:21:52 | Typos in comments: 'it' -> 'if' and 'noityf' -> 'notify'. from Klemens Nanni | ||
| 60ccd8d7 | 2018-01-04 19:06:16 | Back out sign compare changes that appear to cause problems on hppa. Requested by deraadt@ | ||
| 43da03fc | 2018-01-01 19:45:56 | Add WARNINGS=yes to ksh and fix the resulting sign compare warnings. OK tb@ | ||
| b48dd22d | 2017-12-30 07:32:09 | backslash also escapes newlines when quoted; from kshe | ||
| 201e0776 | 2017-12-27 13:02:57 | Add -Wshadow to Makefile and fix the resulting warnings. Many of the warnings are due to the use of globals with generic names, specifically "options" and "path". I've renamed "options" to "sh_options" since it holds the shell options and "path" to "search_path". OK jca@ tb@ | ||
| 855754a1 | 2017-12-26 19:10:31 | The hack for /dev/fd support on systems without it was removed a long time ago. Update the comments and replace test_stat() calls with stat() since test_stat() now just calls stat() directly. Also rename the "mode" parameter to "amode" in test_eaccess() to match access(2) and make it clear that this is the access mode and not the file mode. OK jca@ | ||
| b11c7a77 | 2017-12-18 20:30:14 | Get rid of a todo by stop declaring variable texec as static and instead zeroing it out prior to continuing down the recursive call chain. Initial diff from Michael W. Bombardieri, later tweaked; ok tb@ | ||
| 10bc386b | 2017-12-18 19:04:53 | Add another pair of home/end key bindings; from Lari Rasku. ok jca@ | ||
| 544a6830 | 2017-12-15 20:51:28 | oops - previous should have been a list item; | ||
| f7d60256 | 2017-12-12 11:34:38 | Document change in the default shell prompts. Discussed with and ok jmc | ||
| 0a9a54a3 | 2017-12-12 00:18:58 | Include hostname in shell prompts by default With tmux, ssh and vmd, we tend to open shells on many different hosts simultaneously and the default prompts '$ ' and '# ' for {,k}sh as well as '% ' and '# ' for csh become dangerous: it's very easy to issue a command on the wrong host. This can easily be avoided by displaying the hostname in the prompt. Everything beyond "hostname{$,#,%} " is going to be a matter of taste, so we left it at that. If you use an FQDN, only the first part (the output of 'hostname -s') will be printed. requested by and ok deraadt; mostly positive feedback many ok anton, brynet, bcallah and others | ||
| 311eb4a5 | 2017-12-07 01:54:33 | Drop the unused second argument from set_prompt(). It used to be used for early special casing of ! and !! in the PS1 expansion. This was removed from set_prompt() as part of the implementaion of the character count toggles \[ and \] back in 2004. ok jca | ||
| 0a66aa19 | 2017-11-27 04:23:50 | Follow emacs mode and remove the interactive "version" function. ok jca, anton (who both had the same diff) and deraadt | ||
| 5576e002 | 2017-11-26 20:34:15 | Remove the "version" interactive function in emacs mode. Not bound by default and not very useful. ok schwarze@ anton@ | ||
| 4eb89ea4 | 2017-11-22 12:17:34 | Fix some incorrectness related to Emacs editing mode in ksh: - Keep the order of bindings in sync between the manual and implementation - Fix wrongly documented bindings in the manual - Break out commands without a default binding in the manual ok jmc@ tb@ | ||
| e7db4936 | 2017-11-21 17:57:41 | Initialize *histbase to NULL to fix a bus error in emacs editing mode found by anton. To reproduce, run "env EDITOR=emacs MALLOC_OPTIONS=J ksh" then press "^[_". ok anton, jca | ||
| e1b6fda6 | 2017-11-02 06:55:35 | Switch calloc(3) back to malloc(3). The call to calloc was introduced by the plaintext history diff, but the code that may have depended on this was since removed from history.c. None of the code introduced between the plaintext history commit and now depends on calloc(3). This way we can again use malloc.conf(5)'s J option to recognize use of uninitialized memory. ok jca | ||
| e36d2360 | 2017-10-23 15:43:38 | Kill needless rewind(3) call in hist_init() We may have read two bytes from the file, but history_load() needs to call rewind(3) anyway. ok benno@ | ||
| aae4b320 | 2017-10-23 15:41:39 | Skip (and warn about) overlong history lines. With much input from Ori Bernstein and anton@; ok anton@ (and benno@ on a previous version). | ||
| 57b15f1f | 2017-10-19 07:54:05 | Delete the deprecated emacs-usemeta option. ok tb@ anton@ | ||
| 4a920958 | 2017-10-18 15:41:25 | The return value of this function isn't used. ok anton@ tb@ | ||
| 9b578f98 | 2017-09-07 19:08:32 | Keep histptr inside of the allocated history array histptr == history -1 means that the history is empty, but the behavior is then undefined. Allocate an extra array entry to work around this. Input & ok tb@ | ||
| 2b1380e7 | 2017-09-03 11:52:01 | Use PATH_MAX instead of a local define okk deraadt@ millert@ anton@ | ||
| 6c1c2563 | 2017-09-02 18:53:53 | whitespace commit from BC | ||
| e5989a63 | 2017-08-31 11:10:03 | ignoredups implementation quirk Reminded by tb@ | ||
| 6776170a | 2017-08-30 17:15:36 | Guard FEMACSUSEMETA uses behind #ifdef EMACS | ||
| a725701f | 2017-08-30 17:08:45 | Implement HISTCONTROL ignoredups & ignorespace features ignoredups: don't save the current line if it is identical to the last history line. ignorespace: don't save the current line if it starts with a space ok anton@ millert@ | ||
| 497e8e71 | 2017-08-30 17:02:53 | Stop exposing the emacs-usemeta option, and warn when trying to set it. Unused since 2012, to be removed after 6.2. Input from anton@, ok anton@ millert@ | ||
| 630e2165 | 2017-08-30 16:59:23 | Drop needless comment ok anton@ millert@ | ||
| c2d88b6d | 2017-08-30 10:18:48 | No need for NULL checks before afree() | ||
| 11bd29e4 | 2017-08-29 23:04:50 | Kill a useless setlocale() query Pointless since the removal of the setlocale() call in main.c:rev1.82, the emacs-usemeta flag isn't used in the code since 2012. This kills a chunk of code in a statically linked ksh. ok millert@ | ||
| cfc51100 | 2017-08-28 19:41:55 | Don't bother setting freed history lines to NULL. Dead code that could send the wrong hint to an unsuspicious reader. The code should walk use 'history' & 'histptr' to walk the array. ok millert@, "go for it" tb@ | ||
| 0f120494 | 2017-08-28 19:39:13 | Put history_write() in line with other functions that walk history One method is enough: only access history lines between 'history' and 'histptr'. Pointers outside these bounds might be invalid. ok millert@, "go for it" tb@ | ||
| d03701da | 2017-08-27 17:10:32 | Free history entries when resizing/reloading Cluebat & ok tb@ | ||
| 54cca790 | 2017-08-27 00:29:04 | Remove unused copy_non_glob() in ksh. Report and diff by David Crosby <dave@dafyddcrosby.com> OK otto@ | ||
| 46548ac0 | 2017-08-26 12:34:32 | Don't lose the latest history line & don't crash when shrinking histsize ok tb@ | ||
| cfd7f738 | 2017-08-19 06:19:42 | \$ in PS1 gets you the default prompt character, which differs from the default prompt by not including a space after the character; diff from scott cheloha |