Commit Graph

446 Commits

Author SHA1 Message Date
tg f555d1d524 premark <<< for deletion, >>> for SAR, ^< and ^> for ROL/ROR
cf. http://david.tribble.com/text/c0xrot.htm

noted by izabera
2016-06-25 23:48:10 +00:00
tg 3d130b606a give C_VAR1 precedence over display variable name; izabera pointed out,
rightfully, that, in POSIX shell, ${!#} is defined, and ${!#123} should work
2016-05-05 22:45:58 +00:00
tg 838833ba86 pass on RCSID 2016-03-12 20:45:38 +00:00
tg 842e353011 lintian has new spelling warnings 2016-03-06 21:01:28 +00:00
tg 4ccfd5fab5 document upcoming set +o changes; bump 2016-03-04 18:28:42 +00:00
tg 539714f78a there was a comment on 1015; change comments to match, no code change 2016-03-01 19:22:31 +00:00
tg 143c2aa69c bring documentation of command up to date wrt. POSIX and whence wrt. command
(inspired from a bugreport by Martijn Dekker who noted this is currently broken)
2016-02-26 19:38:42 +00:00
tg 19ab699100 fix working with ditroff on Schillix, confirmed by Jvrg 2016-02-11 19:00:50 +00:00
tg 91ae6ad199 update 2016-01-20 22:04:54 +00:00
tg c51e067e62 incorporate more feedback from schily 2016-01-14 23:18:11 +00:00
tg 2492c5692b incorporate suggestions by J�rg Schilling 2016-01-13 17:20:52 +00:00
tg 678fd25b36 be clearer on what we do to the array on read -a other than clearing it 2016-01-12 16:33:17 +00:00
tg f0b83e194a future directions; izabera’s got a point and we’ll need two locales (C and
C.UTF-8), but we’ll need this in MirBSD a̲n̲d̲ audit its scripts first
2015-12-31 20:25:48 +00:00
tg b2b0c0bbb6 update for recent changes 2015-12-12 22:25:15 +00:00
tg cef386fb60 make “source” into a built-in command (keepasn, to match ksh93 and “dot”);
remove the “stop” alias and drop old Android and OS/2 hacks and auto-unalias
2015-10-09 21:36:59 +00:00
tg 52b0370973 some doc overhaul/bugfixes; TODO: document all of FPOSIX, FSH deltas
(after working through lksh.1 and deciding on them)
2015-10-09 20:43:11 +00:00
tg 4adcfe8b58 oksh sync, simplify *all* if(x)free(x); constructs, simplify x_push() and sync boilerplate while here 2015-09-05 19:19:12 +00:00
tg 92978953b2 ; on OS/2 2015-08-13 22:09:10 +00:00
tg 0df20b04b8 documentation update (external links), from _0bitcount via IRC 2015-07-12 19:09:50 +00:00
tg fd37f4baf0 POSIX doesn’t like the OPTU encoding scheme due to btowc/mbtowc asymmetry,
so make all utf8-mode behaviour implementation-defined (and document the
raw octet mapping more explicitly)
2015-07-10 19:35:39 +00:00
tg 0fd9337123 implement support for PC scancodes à la CHR$(0)+CHR$(&h48)
superseding an mksh-os2 patch which confirmed this is needed

Reference: my copy of the Schneider EURO PC manual 50032 for
Microsoft® GW-BASIC
2015-07-10 18:41:07 +00:00
tg dcd8b6389b apply the new cat hack to printf, too, to prefer it over the builtin 2015-07-09 20:20:45 +00:00
tg 483536e336 point out mknod is not normally part of mksh either 2015-07-09 19:50:44 +00:00
tg f463d9da76 • revert the cat hack for realpath and rename
‣ I was convinced by several that more magic is never the solution
• fix a comment: function cat already had precedence
• change cat loader to look for existence, FPATH included, before
  ditching the builtin; note that in manpage
2015-07-06 17:48:37 +00:00
tg e0196f47d5 implement completely new multiline code by delaying history store
this commit is valgrind-tested
2015-07-05 19:37:18 +00:00
tg 48af854117 fix 'command -v' for "shell reserved words"
From: Martijn Dekker <martijn@inlv.org>

also adjust manpage accordingly
2015-07-05 17:50:40 +00:00
tg b9a8fdf905 implement cat thing for realpath and rename too: if flag, call external 2015-07-05 15:45:18 +00:00
tg b478d334d9 merge spelling stuff from oksh 2015-07-05 15:22:41 +00:00
tg 0bdc395a81 permit read -N n (n ≠ -1) and read -t to return partial reads with $? == 1
issue spotted by carstenh, could have been a documentation ambiguity issue
(as -N was designed to read and return exactly n bytes), but this resolves
it in a way both backwards-compatible and user-pleasing
2015-06-28 14:57:25 +00:00
tg babd9c4cf0 The check for empty patterns and patterns matching the empty string
in commitid 1004D8283F068C41C3C was bogus; it fixed Jb_boin’s issue
but izabers’s 「var=foo; echo "${var/*/x}"」 was broken; in fact we
only want to not do the looping for // if the pattern matches much.

Also, fix a spelling mistake in the manpage and change some wording
to also work with associative arrays (in the future; no change).
2015-05-23 17:43:22 +00:00
tg 93ccb42114 overhaul the signal handling:
• support NSIG_MAX from http://austingroupbugs.net/view.php?id=741
  and make a TODO for later to use sysconf(_SC_NSIG) at runtime
• bounds-check signals (e.g. no smaller than 1, but smaller than NSIG)
• align trap errorlevel with other shells
• make trap match what’s in POSIX and fixup the manpage
• refactor some code related to signals
• hide from kill builtin both EXIT and ERR pseudo-signals
2015-04-29 20:44:37 +00:00
tg 4a33198f45 manpage fixes (mostly \-x to Fl x inline) 2015-04-29 20:13:26 +00:00
tg 0661df9940 fix lies; this had to be taken out for security reasons some time ago 2015-04-29 18:56:00 +00:00
tg 82bc5eba9a give a better suggestion: find|read → find|&read 2015-04-29 18:54:05 +00:00
tg c9ccf0bab7 MFC remaining fixes; tested locally a lot, plus remotely with
GNU C11 (Debian 20150413-1) version 5.0.1 20150413 (prerelease) [gcc-5-branch revision 222050] (x86_64-linux-gnu)
including ASan (testsuite) and Valgrind (short)
2015-04-19 19:18:07 +00:00
tg 4bea0cc227 MFC most things (see mksh.hts) to R50-stable; sync clog 2015-04-12 22:32:12 +00:00
tg cad9bc86d3 Implement the “FKSH functions have local scope for shell options” feature
for mksh but not lksh; bump to R51-alpha.

While here, tweak build scripts a bit, fixup MirBSD-specific Makefile
things, remove part of a comment that’s uninteresting.
2015-04-11 23:28:21 +00:00
tg 3251f18c12 document code to make mksh set ±U match the user locale from the environment
cf. http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/1246729/focus=606
2015-04-11 22:35:10 +00:00
tg 6b00977053 just another oksh rcsid-only sync (we bind to the Delete key since forever) 2015-04-11 22:09:49 +00:00
tg 0620a5d034 sync clog 2015-03-21 00:12:46 +00:00
tg 8967f13bc6 oksh rcsid-only sync, plus a fix in the commit whose body I skipped
sync’ing, plus a bonus fix inspired by their commits in sh.1…
2015-03-20 21:23:52 +00:00
tg 0d72355038 “local x=$1” is supposed to not field-split and so 2015-03-14 05:23:18 +00:00
tg 532af35304 oksh rcsid sync; we have no set -o csh-history, and the manpage changes are just wrong, so, a nop 2015-03-14 05:17:17 +00:00
tg 8f53c68265 • protect POSIX builtins and utilities from aliases, e.g:
‣ : → \:
  ‣ alias → \alias
    ⇒ except in some internally used cases, where we use \builtin alias
  ‣ command . → \command .
• protect Korn Shell builtins from aliases and functions, e.g:
  ‣ typeset → \builtin typeset
    ⇒ also unravels the “local” alias used
  ‣ print → \builtin print
• protect internally-used things from aliases
  ‣ “let]” is not a valid function name
  ‣ “set” is POSIX so we don’t expect anyone to override it in a function
• use “command -v” instead of “whence -p” (“which”) in most
  places; thanks izabera from #ed on IRC for pointing out
  that “command -v” is POSIX – except, “whence -p” a̲l̲w̲a̲y̲s̲ looks
  for an executable and shows its full pathname; “command -v”
  also resolves to aliases, functions and builtins, so only use
  it where it makes any sense (both never output to stderr)
• make most of dot.mkshrc work in the face of such aliases
  ‣ “ulimit -c” is used; this is not POSIX, and not portable;
    maybe we should make ulimit accept-and-ignore the most
    common limits even if the OS doesn’t use them?
• update list of builtin aliases in the manpage
2015-03-08 22:54:36 +00:00
tg be147e3426 SECURITY: make “unset HISTFILE” really work
additionally, make “HISTFILE=” the same, document the truncation and
re-reading process’ further and already-known bugs; this needs work
2015-03-07 20:46:31 +00:00
tg d3f3c3ec22 it’s probably useful to define a marker like this, for automated patching,
e.g. in SuSE’s shells/mksh specfile, since they insist on a vendor patch,
as PLD does
2015-03-05 13:30:57 +00:00
tg e3acd9c76a MFC everything except the igli-inspired changes to jobs.c and the
.Ox Ns -inspired integer base changes .
That means: bugfixes, plus the new arguments to exec (feature)
2015-03-01 15:43:09 +00:00
tg f6f49a119b add getopts for exec (unbreaks “exec -- /bin/ls”) and steal -a and -c from ksh93 2015-02-06 10:56:49 +00:00
tg 934929c2ee rcsid sync from obsd; misc sync; small improvements
• mksh testsuite no longer uses printf, again
• use MAXPATHLEN from <sys/param.h> as PATH_MAX fallback
2015-01-25 15:23:43 +00:00
tg e60f3e494b future directions 2014-12-18 20:51:12 +00:00
tg f66c194f29 oksh sync RCSIDs only:
• expr.c long done already
• mksh.1 does not apply to us (no character classes)
2014-12-15 23:26:36 +00:00
tg 93448bdf66 bit more on POSIX 2014-11-25 22:46:47 +00:00
tg f491c25cab add a warning about not using tainted user input in arithmetics;
Stéphane Chazelas may write something more detailed we can then link to
2014-10-07 15:30:12 +00:00
tg 478a2af837 wording 2014-10-03 12:35:38 +00:00
tg dbedf50316 document HISTSIZE limit 2014-09-24 10:47:11 +00:00
tg 0a87a59b47 keeping up with the jones; RCS ID sync only:
we already fixed the list of builtins ages ago,
and don’t use weird unportable ioctl(2)s
2014-09-12 20:23:33 +00:00
tg 80b8966367 fix lies introduced in mksh R17, as part of the undergoing IFS investigation 2014-07-29 17:26:24 +00:00
tg 6c31e7e631 document symmetric remainder is used by % and how to get mathematic modulus
researched during trying to figure out wtf LP#1348614 item 3 i̲s̲
2014-07-25 21:38:51 +00:00
tg 679240fd97 make it clearer when a shell is interactive
spotted, and help with sentence structuring, by Andreas Buschka
2014-07-21 08:06:16 +00:00
tg 9d80a50837 fix manpage; From: Ypnose <ypnx@mailoo.org> 2014-07-03 20:47:56 +00:00
tg d2ef1d5d2c bump 2014-06-24 20:47:47 +00:00
tg 129ba5c584 fix the “set ±p” issue for good
cf. http://blog.cmpxchg8b.com/2013/08/security-debianisms.html
2014-06-09 12:28:19 +00:00
tg 7734e07d12 oksh sync 2014-06-09 11:22:50 +00:00
tg ccf991486f doc issue (because no regression… even if it works in ksh93):
19:09 < nDuff> I'm reading the following behavior as contrary to the documentation. Could someone clarify?
19:09 < nDuff> $ words_pat='*@(cat|mice)*'; [[ 'there is a {cat}' = $words_pat ]]; echo $?
19:09 < nDuff> 1
19:09 < nDuff> $ [[ 'there is a {cat}' = *@(cat|mice)* ]]; echo $?
19:09 < nDuff> 0
2014-06-06 23:50:22 +00:00
tg b76c28c08b use termcap(5) names, not terminfo(5) names, in tput(1) examples,
since only the former work in FreeBSD/MidnightBSD

thanks to jilles, discovered by pekster, on IRC
2014-03-07 22:47:49 +00:00
tg a11bd30cba oksh sync, mostly
• keep the Kochan book at 3rd edition because 4th is not a paper book

• keep POSIX at 1993 because I’m actually unable to find an ISBN or
  other bib ref for the 2013 version…
2014-02-05 18:07:29 +00:00
tg 8b40ae5de1 hint more on vi mode limitations; requested by Philipp von Bassewitz 2014-01-21 20:58:32 +00:00
tg 270a86f895 • use BAFH for hash ipv NZAAT
• prep for release
• fix minor nits in manpage and tests
2014-01-11 18:09:43 +00:00
tg 89e774fd7e • fix ${12345678901234567890} segfault (OOB access / integer overflow)
‣ not like oksh did, but using mksh’s built-in features
• handle suggested __pure additions
• revert cid 1004F7F096867C83CF0
  ‣ always use our wcwidth code
  ‣ only use our strlcpy code if none found
• fix a couple of gcc-snapshot and clang/scan-build warnings
• mksh R49~rc1
2014-01-05 21:57:29 +00:00
tg d8b65ff642 oksh bumped array indicēs again, INT_MAX this time, still less than mksh… 2014-01-05 19:14:18 +00:00
tg d22296d595 make octal in arithmetics better greppable (cf. Debian #732509)
XXX maybe make an entire .Ss or .Sh out of delta against posix? other sh?
2013-12-18 16:54:20 +00:00
tg 0dfbf3d314 note that even set -o noclobber can be coërced into dropping O_EXCL by a TOCTOU 2013-11-30 18:16:54 +00:00
tg 2008bab5a0 mention negative history numbers (thanks odc:#!/bin/mksh for noticing) 2013-11-17 22:24:06 +00:00
tg 44a58fb3e9 drop RLIMIT_LOCKS completely, it was for early Linux 2.4 versions only 2013-11-17 22:20:21 +00:00
tg 2e7509548a integrate latest changes from oksh: Wed Sep 4 15:49:19 2013 UTC by millert
Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP.  Login shells
may be suspended if they are not running in an orphan process group.
2013-09-10 17:33:04 +00:00
tg fda010d8de SECURITY: Unbreak “set +p”, broken by OpenBSD ksh change.
TODO: I am seriously considering following Chet and changing
the way this works, by explicitly dropping privs unless the
shell is run with -p. Every other shell does it like mksh,
except Heirloom sh, which on the other hand doesn’t know any
explicit set -p or set +p (though it doesn’t know set +foo
for any foo either).

┌──┤ QUESTION: Do we need the ability to do this:
│ tg@blau:~ $ ./suidmksh -p -c 'whoami; set +p; whoami'
│ root
│ tg

If not, I’m seriously considering to drop set ±p as well,
only parse -p on the command line, with +p being the default,
and dropping FPRIVILEGED.

Thanks to RT for noticing and jilles for initial follow-up
discussion, as well as Chet Ramey for doing the sane/secure
thing instead of following Debian.
2013-08-23 14:07:39 +00:00
tg 64d828ac07 try to be even more clear 2013-08-10 14:11:39 +00:00
tg c10e5bd237 reduce amount of .bss memory needed; initialise via AEDIT at x_init
or even first run of x_vi
2013-08-10 13:44:33 +00:00
tg ead77623d3 Fix most “set -x” problems (LP#1179287)
• “set -x” manually (cmdline too) snapshots fd#2 now
• “set -o inherit-xtrace” introduced; default still enabled
• reverted iodup printing to pre-R45 behaviour
• made Flag(FXTRACE) a proper state machine
2013-07-21 18:47:24 +00:00
tg bd795a83ae partial merge and full RCS ID sync with oksh
merged:
• new regression tests
• check.pl (tests/th) better tmpfile handling
• exec.c 1.50: POSIX specifies that for an AND/OR list,
  only the last command's exit status matters for "set -e"
• ksh.1 1.147: document the above
• eval.c 1.39: “Make $(< /nonexistent) have the same behaviour
  as $(cat /nonexistent) wrt. errors (do not unwind and do not
  treat this as fatal if set -e is used).”
  ‣ additionally make shf_open() return errno and actually show
    the error message from the system
• regression-39 test: remove the “maybe” marker
  ‣ but decide on correct POSIX behaviour

already been fixed in mksh:
• check.pl (tests/th) exit 1 if tests fail

not merged:
• main.c 1.52: run traps in unwind() before exiting;
  I’m pretty sure this is already working as-should in mksh
• eval.c 1.38: “Commands executed via `foo` or $( bar ) should
  not inherit "set -e" status.” As discussed in IRC, this is
  just plainly WRONG.
2013-07-21 18:36:03 +00:00
tg 8e6b0f712a support n̲o̲t̲ fork(2)ing for -T (by prepending the tty with ‘!’); especially useful on Linux since our own setsid(2) is more annoying; gets rid of the need for oneit_lite and similar hacks; WARNING: also removes chown/chmod on the tty! 2013-06-03 22:28:06 +00:00
tg 1d0409d932 implement VALSUBs 2013-05-02 21:59:54 +00:00
tg ff42a866e9 implement set -o pipefail 2013-05-02 20:28:15 +00:00
tg f2906c79df for Yofuh: implement Emacs mode PgUp as Vi insert mode CurUp 2013-05-02 15:33:30 +00:00
tg 689c179254 sync and be even more explicit
XXX some day, write the *precise* delta of MKSH_LEGACY_MODE into lksh.1
2013-04-27 19:16:27 +00:00
tg dc94c3d205 after enough complaints by POSIX sh advocates,
• make parsing numbers with leading digit-zero as octal independent of
  mksh/lksh and dependent on set -o posix; adjust manpages to match
• warn about these changes and why mksh uses 32-bit consistent arithmetics
  and point people to lksh for host-long undefined-behaviour arithmetics
• point out, explicitly, that it is *legal* for the operating environment
  to make 'print $((2147483647 + 1))' (on a 32-bit system; adjust for a
  64-bit system) to run 'rm -rf ~ /' instead
2013-04-27 18:50:25 +00:00
tg deb4a3bf20 Oh well… this looks well, is done done, and gcc-snapshot doesn’t complain:
• correct order of built-in commands; use POSIX special versus “all others”
  plus “keeps assignments” as distinction, no longer play POSIX regular vs.
  others game; sync manpage
• fix LP#1156707: map (( internally to “let]” which is no valid function
  name and so can’t be overridden but is unlikely to be used otherwhere
  and not strictly permitted (by POSIX) anyway
• we do not need -Wno-overflow any more, either
• bump to R45
2013-04-26 21:22:50 +00:00
tg 1df3efdb86 another intermediate step/commit to get arithmetics right:
do the correct operations for comparisons (just keep using the
signed/unsigned switch from bivui for them), division (by working
on absolutes and adding the sign at the end), modulo (stupidly by
divising in signed, multiplying and subtracting, to get the sign
of the result right)

also adds rotation

XXX to check: do we need to AND before assigning the result in division?
2013-04-14 13:36:53 +00:00
tg 94dfda0be0 RCSID sync w/ oksh; whitespace (KNF) 2013-03-24 21:34:14 +00:00
tg a3b5e77c6c disable parsing of &> as GNU bash iop if -o posix or -o sh, based on IRC discussion where jilles(IIRC) pointed out it breaks existing valid scripts 2013-03-24 15:01:50 +00:00
tg 4b2e17b828 • let mksh “set -x” print whole TCOM trees
• plug some memory leaks in debug (“set -x”) and warning paths while here
• one from Florian (friend of Natureshadow) for WTF
2013-03-24 00:56:27 +00:00
tg 74e2ef8b0b one more int → bool; mention “set -o sh” may (on raare OSes) be enabled
automatically (and it differs between targets); test MidnightBSD 0.1 ash
compat code and adjust the testsuite so it passes with it enabled
2013-02-19 18:45:22 +00:00
tg 2c76875ea3 • Document invalid ${a/b/c} patterns in manpage (Debian #698678)
• add speed hints and misc improvements; bump version
2013-02-11 17:17:59 +00:00
tg 63cf38eca7 sync description for funsubs 2013-02-10 23:58:19 +00:00
tg 24164e07d4 rcsid-only sync 2013-01-19 17:27:05 +00:00
tg 77c4cb88e4 implement tty tracking and bump to R41 for feature completeness
• tty_fd is now never closed
• new tty_hasstate tracks tty_state (cf. thread around
  http://article.gmane.org/gmane.os.miros.mksh/79 and PLD bug)
• as users requested, importing COLUMNS or LINES from the environment
  now removes its special-ness as does unsetting it
• otherwise, setting COLUMNS or LINES is honoured until the next SIGWINCH
  arrives or change_winsz is otherwise run (e.g. before displaying the
  prompt in the interactive command line editing modes)
• SIGWINCH is now honoured before each reading of $COLUMNS and $LINES too
• change the Uhr to match – it no longer calls stty(1) ☺
2012-11-30 19:25:08 +00:00
tg 007cf09db6 use EPOCHREALTIME as variable, somewhat compatible with “zmodload zsh/datetime”, as ormaaj belatedly found out 2012-11-26 22:49:51 +00:00
tg f284261018 • update documentation and references
• say R41, we’re almost feature-complete, and the missing one
  will not require documentation updates
2012-11-20 18:25:12 +00:00
tg 13da062f92 add MKSH_UNIXTIME 2012-11-20 18:07:45 +00:00
tg 435bc124ef introduce $BASHPID for ormaaj from #ksh 2012-11-20 17:42:32 +00:00