Commit Graph

770 Commits

Author SHA1 Message Date
KO Myung-Hun 759b6ec59f Consider OS/2-style path
OS/2 uses 'x:' as a drive prefix and '\' as a directory separator.
2015-06-03 13:00:43 +09:00
KO Myung-Hun a03cf65602 Consider executable extensions in case of some test commands on OS/2
-r, -w, -x, -a, -e, -f.
2015-06-03 13:00:42 +09:00
KO Myung-Hun 5127457319 Read in text mode, write in binary mode on OS/2
This enables to convert CR+LF to LF when reading, but disables to
convert LF to CR+LF when writing.

Instead, however, CR+LF are not passed into mksh as is.
2015-06-03 13:00:41 +09:00
KO Myung-Hun 5ed2481df2 Try to append executable suffixes if not having extension on OS/2 2015-06-03 13:00:40 +09:00
KO Myung-Hun 8f633da789 Path separator is ; on OS/2 2015-06-03 13:00:40 +09:00
KO Myung-Hun aeeabefbe5 Do not define getrusage() stuffs on OS/2 kLIBC
OS/2 kLIBC has only a declaration of getrusage() without implementation.
Due to this, definition of getrusage() stuffs causes compilation to fail.

-----
In file included from lalloc.c:21:
sh.h:379: error: conflicting types for `getrusage'
f:/lang/gcc/usr/include/sys/resource.h:168: error: previous declaration of `getrusage'
-----
2015-06-03 13:00:39 +09: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 609b311919 more low-hanging fruits for EBCDIC; notes:
• ord() new, From: Daniel Richard G. <skunk@iSKUNK.ORG>
  ‣ used in some places
• (c - '0') → ksh_numdig(c)	# may take *x++ argument
• (c - 'A') → ksh_numuc(c)	# may NOT take *x+= argument
  ‣ idem for ksh_numlc(c) and 'a'
  ‣ these need changing for EBCDIC
  ‣ add testsuite for this
• use macros more, they exist already often
• use digits_lc[foo] instead of ('0' + foo), especially for letters
• caught another ksh_eq case…
• also caught a maybe-UB overflow check, but we don’t have TIME_T_MAX ☹
2015-04-29 20:07:35 +00:00
tg 3eb806b72b inline only user of ksh_min, make it more cool; drop ksh_min, ksh_max;
move ksh_isdigit etc. to ksh_isalpha etc. definitions
2015-04-29 19:11:57 +00:00
tg 2cb0ea982a EBCDIC helpers and OS/390 signals 2015-04-29 18:38:54 +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 65f9b93926 ordinarily, lineno must be mksh_uari_t, but edit.c most of all isn’t ready,
so we mitigate a bit (in var.c mostly) and tweak another type already, and
add some checks (mksh_{,u}ari_t must fit into {,unsigned }long) and print
line numbers with %lu already
2015-04-19 18:50:38 +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 e1cda74d04 SECURITY: fix integer overflows related to file descriptor parsing
bug initially found by Pawel Wylecial (LP#1440685)
additional bug found and suggested fix by enh (elliott hughes)

This commit also renames struct ioword.flag to ioflag to disambiguate
it from other members named “flag”, changes it to an unsigned type,
and packs ioflag and unit into shorts each, to make the struct smaller
(aligned even: 16 bytes on 32-bit systems) and reviews some of the
code involved in fd handling, though there wasn’t much to be found.
2015-04-11 22:03:32 +00:00
tg 07898d8a45 only lksh now implies unalias for a POSIX function definition (used e.g. in Debian sysvinit scripts that use a “stop” function) 2015-03-20 23:37:55 +00:00
tg 2097d45f7f oksh rcsid-only sync, plus bonus rewrite of strip_nuls
(uses size_t ipv int for buffer size now, and no extra
calls to memchr/memmove, input is typically small)
2015-03-20 21:46:41 +00:00
tg 0d72355038 “local x=$1” is supposed to not field-split and so 2015-03-14 05:23:18 +00:00
tg 96d9e5d1f1 remove unused CMDWORD 2015-03-14 04:37:55 +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 fcc59eee48 remove some unused string pooling stuff 2015-03-08 21:30:22 +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 707add559f keep “set -x” disabled during PS4 expansion, to avoid infinite looping 2015-03-01 15:23:05 +00:00
tg f4ae6f7508 can't set word=IFS_QUOTE if already IFS_WORD (something there)
or IFS_QUOTE (third dquote (second OQUOTE) in """something)
2015-02-20 07:14:30 +00:00
tg 73082b9292 • fixup here document expansion (regression wrt. pdksh 5.2.14)
• adjust testsuite (and write tons of new tests) after today’s commits
2015-02-19 22:26:50 +00:00
tg 4157cca352 oksh sync; unsure if it applies (with us using old_source and all) but
better be safe than sorry; it at least passes our testsuite

NOTE: people who can figure out how afl can be used for mksh welcome! ;-)
2015-02-13 12:51:33 +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 e49d7bc3c6 better 2015-01-04 21:08:10 +00:00
tg 51c370459e bump version and, also, year… I hate this… 2014 is gonna follow us for a while… 2015-01-02 13:21:28 +00:00
tg dcdc828c41 fix here string parsing problem found by Stéphane Chazelas 2014-12-15 22:50:11 +00:00
tg 2f52b993a1 • Build.sh: fix NSIG detection for gcc-snapshot
• all: bump version to R50-current; add more comments; whitespace
• all: remove all mkssert(); we’ll do full re-runs of scan-build and,
  hopefully, Coverity Scan/Prevent
• check.t: fix a testcase (sed could exit false, but we don’t care)
• eval.c: fix tilde_ok data type (only unsigned may shl constantly)
• exec.c: fix shebang buf array accesses to always go via uint8_t *
2014-11-25 21:13:31 +00:00
tg 517bd63fe5 rename the “tilde” function; apparently, some system headers define it 2014-11-19 21:49:12 +00:00
tg 9b31399aec fix buffer overflow found by zacts from IRC (bad length calculation)
now zsh and mksh are even… :|
2014-11-19 18:44:11 +00:00
tg 8d9d86ceab mark two ($@/$* expansion-related) testcases as expected-fail, with more to come ☹ 2014-11-14 20:21:29 +00:00
tg 44dc99cb35 first cut at LP#1381993 (probably incomplete) plus test coverage
also remove fbsd testsuite link, it’s gone during cvs→svn of theirs ☹
2014-10-19 21:53:08 +00:00
tg 2fd0482761 commit patch from LP#1381965 and two testcases, one showing this is fixed,
another showing deeper problems (probably LP#1381993 “non-list contexts” or
the IFS_WS/IFS_IWS story, perhaps *all* IFS_WS (not just ternaries) really
should be IFS_IWS instead?)
2014-10-19 20:56:33 +00:00
tg 996e05548a POSIX says “command” loses SPEC_BI and means it too
reported by ormaaj, who even asked on the austin ML
http://thread.gmane.org/gmane.comp.standards.posix.austin.general/9907/focus=9931
clarified by jilles; also make errorlevels match ksh93
2014-10-12 21:58:53 +00:00
tg 4afe543fa0 fix x+=<< 2014-10-12 19:55:01 +00:00
tg 0cf0658a0d fix severe regression in field splitting (LP#1378208) 2014-10-07 15:22:17 +00:00
tg 40954ce437 fix null pointer deref on empty nameref assignment (no ‘=’)
found by Goodbox on IRC
2014-10-04 11:47:19 +00:00
tg 968dc7a764 overhaul IFS handling, fix bugs reported by Stephane Chazelas and mikeserv
now we’re at: 486 passed testsuite items, 0 failed
ifs.sh still: # tests 6856 passed 6856 failed 0
2014-10-03 17:32:12 +00:00
tg 26f15bd938 permit $1, $!, etc. to be nameref’d again ($_ was); spotted by Jb_boin, 10x! 2014-09-03 19:22:51 +00:00
tg 097ed42c83 https://android-review.googlesource.com/102253
• permit interrupts during a write(2) loop in the cat builtin, too,
  not just in the read(2) loop – fixes inability to kill a clogged
  output cat

• kill the cat when smores finish

TODO: revisit this ⓐ in more depth, ⓑ for other functions, such as
      “hd”, and ⓒ test on AOSP as well
2014-07-28 21:45:45 +00:00
tg 0eb5044ac6 fix rare infinite loop when invalid UTF-8 is in the edit buffer
From: Ivan “Colona” Delalande <colona@ycc.fr>
2014-07-13 11:34:29 +00:00
tg e4c01375aa fix access-after-free crash spotted by Enjolras via IRC, thanks! 2014-06-29 11:28:28 +00:00
tg d2ef1d5d2c bump 2014-06-24 20:47:47 +00:00
tg edc80f317c remove old/unused stuff 2014-06-24 18:51:37 +00:00
tg 73edeaa8ec fix “set -o pipefail” w/o PIPESTATUS, and PIPESTATUS inside COMSUBs and other sequences 2014-06-10 22:17:10 +00:00
tg 7330970bfa fix some of the signal stuff (still didn’t get rid of awk(1) and printf(1)
calls in Build.sh, we need HOSTCC for that… which we should do, using BER
or something encoded for integers, and pregenerated hashtables as planned)

also, bump to R50 beta, due to today’s language changes
2014-06-09 13:25:53 +00:00