Commit Graph

772 Commits

Author SHA1 Message Date
KO Myung-Hun 834349f3be Merge remote-tracking branch 'mksh/master'
Conflicts:
	Build.sh
	check.pl
	check.t
	edit.c
	emacsfn.h
	exec.c
	funcs.c
	main.c
	misc.c
	sh.h
	var.c
2015-07-21 16:30:46 +09:00
tg abfde383fe git@github.com:komh/pdksh-os2 commit 590f2b19b0ff92a9a373295bce914654f9f5bf22
says to use <termio.h> not <termios.h> on OS/2

From: Ilya Zakharevich <ilya@math.ohio-state.edu>
2015-07-10 17:16:23 +00:00
tg edf76ec8e6 harden the crlf vs lf tests even more; use binary mode explicitly on OS/2 2015-07-09 20:52:43 +00:00
tg f274f18223 SECURITY: quote the arguments to true 2015-07-09 20:11:45 +00:00
tg d034be7a84 more mksh-os2 inspired hackery 2015-07-09 19:59:14 +00:00
tg 950827394b more easy OS/2 fixes
From: KO Myung-Hun <komh@chollian.net>
2015-07-09 19:46:43 +00:00
tg 041666eefb a few more mksh-os2 inspired fixes 2015-07-09 19:28:21 +00:00
tg 3d8ba005e1 add a few generic fixes from mksh-os2
From: KO Myung-Hun <komh@chollian.net>
2015-07-09 19:19:10 +00:00
tg e88316739e merge from git@github.com:komh/mksh-os2
Use gcc on OS/2

From: KO Myung-Hun <komh@chollian.net>
2015-07-09 19:04:28 +00:00
KO Myung-Hun 65d8ad9dae Merge remote-tracking branch 'mksh/master' 2015-07-08 19:31:55 +09: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 b9a8fdf905 implement cat thing for realpath and rename too: if flag, call external 2015-07-05 15:45:18 +00:00
KO Myung-Hun c8bdf4d149 Define MKSH_NOPROSPECTOFWORK on OS/2
Strangely, sometimes mksh is blocked when it is running in a background
console, that is, a window not having a focus.
2015-06-03 13:00:48 +09:00
KO Myung-Hun a1a8bd3f42 Define MKSH_UNEMPLOYED on OS/2 2015-06-03 13:00:46 +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 c29f892437 Ignore size on OS/2
Size does not support OS/2 OMF executables.

-----
size mksh.exe
size: mksh.exe: File format not recognized
-----
2015-06-03 13:00:39 +09:00
KO Myung-Hun fb22b94007 Executables have .exe extension on OS/2 2015-06-03 13:00:39 +09:00
KO Myung-Hun a4139c6666 Use gcc on OS/2 2015-06-03 13:00:38 +09:00
tg a9e1101145 sync with actual z/OS <signal.h> contents 2015-05-01 16:08:26 +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 4e313e705d improve install notes, mention lksh, as requested by Ypnose via IRC 2015-04-29 20:39:00 +00:00
tg 55c3fb35d8 more OS/390 issues 2015-04-29 20:13:47 +00:00
tg 2cb0ea982a EBCDIC helpers and OS/390 signals 2015-04-29 18:38:54 +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 b5d3b38cb1 port this to GNU bash 1.12.1 from http://www.qemu-advent-calendar.org/#day-1 2014-12-08 12:20:40 +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 d25612b4b0 stop using ptrdiff_t 2014-11-25 20:00:39 +00:00
tg 0cf0658a0d fix severe regression in field splitting (LP#1378208) 2014-10-07 15:22:17 +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 e239a8358a use issetugid(2) as additional aid in determining if we are FPRIVILEGED 2014-10-03 17:19:27 +00:00
tg 8f172270f9 fix link; found by zacts 2014-09-29 18:57:00 +00:00
tg b764054000 more rare signals 2014-09-04 23:06:51 +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 9b1d8d9f04 eglibc is merged back into glibc; adjust comment 2014-07-04 11:03:52 +00:00
tg a375a7b2b6 use -fstack-protector-strong in favour of -fstack-protector-all if we can 2014-06-29 10:56:08 +00:00
tg d2ef1d5d2c bump 2014-06-24 20:47:47 +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
tg 495b798893 improved OE reporting for newer Darwin/OSX, by Ryan Schmidt <ryandesign@macports.org> 2014-05-27 13:41:53 +00:00
tg 033e1f4b9e fix LP#1277691 (“nameref RHS not syntax checked”) and the inability to
use errorf() while nameref states were being changed (by almost completely
eliminating the global variable) and the readonly first array variable
bypass (typo/refactoro); also, whitespace, one int → bool, and add a
comment wrt. the parser rewrite talked about with igli during a fever ;)
2014-05-27 13:22:46 +00:00
tg 8b88eb3c9b avoid UB in LFS test (Debian #742780) 2014-03-28 12:08:25 +00:00
tg a1946ba7b8 honour $TMPDIR in test.sh for use as scratch space 2014-02-08 20:20:17 +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 d49d03a095 read’s -r option is not portable; discovered by RT 2013-12-02 19:47:33 +00:00
tg 6217904193 detect getsid(2), also spotted by RT, this on MSYS 2013-11-30 17:41:35 +00:00
tg 7cae22ef5c zsh on BeOS calls sigsuspend() on “dot”, which fails; work around it
tested by RT
2013-11-30 15:42:19 +00:00
tg 73106b6e75 make this actually call getopt.sh, correctly, and Heirloom sh compatible 2013-11-20 21:14:50 +00:00
tg be9bd4c543 static option creating for cmdline and set, too
(in preparation of doing something real with set ±p)
2013-11-17 22:22:56 +00:00
tg d1245ee13a more clueful (automatic) getopt string generation 2013-11-17 22:21:18 +00:00
tg cf40c01b45 adapt most __attribute__((…)) occurrences to new KNF style(9) 2013-10-31 20:05:39 +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 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 c7f483c16f also protect the icon file from accidental deletion, and merge the cases 2013-07-25 17:01:03 +00:00
tg aeea5fd22a rewrite lots of “elif test” into “case” statements
(except those where the condition isn’t related)
2013-07-25 15:54:33 +00:00
tg 31d36b6611 Plan 9 support patch from Jens Staal 2013-07-25 15:43:59 +00:00
tg 8d0a5e6dbe align the compile-time asserts double-check struct size with padding 2013-07-25 15:36:18 +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 80a83f4f0b use ${SIZE-size} for lewellyn’s cross 2013-07-08 10:12:45 +00:00
tg 6aa08008b3 replace warnings for sig_t detection 2013-06-03 22:27:15 +00:00
tg 8256f266ff fix a number of warnings and other issues:
• sig_t detection was a bit insane, it is a function-pointer type after all
• fix uninitialised variable in c_select which led to mistakenly accepting
  invalid (nōn-numeric) input and acting, randomly, upon it
• keep SIGCHLD blocked in child after forking longer, for job list manip
• block SIGCHLD ifdef DEBUG_LEAKS to not run job foo during/after afreeall
• fix annoying ISO C90 vs. C99 (un)signed constant warning
2013-06-02 03:09:17 +00:00
tg 49d1ebfb71 Replace wcwidth code by mine based on Unicode 6.2.0 2013-05-31 23:27:14 +00:00
tg 407734d305 meh, wrong gcc flag 2013-05-22 19:24:32 +00:00
tg c8a3127ea7 • fix error in warning fix (hah!)
• if GCC add -Wno-deprecated for dietlibc (and others) idiocy
2013-05-22 18:56:50 +00:00
tg d4bf779c7e also from Sylvestre Ledru’s clang-using Debian buildd, quieten another configure time warning; log before running that /dev/{null,tty} exist (with ls -l, so we see they’re actual devices) 2013-05-08 11:30:45 +00:00
tg a072c63fe8 declare thiswillneverbedefinedIhope to silence some configure time warnings 2013-05-08 11:16:19 +00:00
tg f02f8afe6e • don’t accidentally remove lksh.1 from the srcdir for in-srcdir builds
• fix post-build non-‘-Q’ output for lksh

both discovered in Fedora; thanks rsc
2013-05-05 13:38:00 +00:00
tg 1d0409d932 implement VALSUBs 2013-05-02 21:59:54 +00:00
tg f0f34eb7b6 • Allow setting both -o posix and -o sh (although only in the same
command; setting one still unsets the other at first)
• Change subst_exstat to be conformant unless -o sh is set and -o posix isn’t
• In lksh, make subst_exstat (newly) conformant if -o posix
• New MKSH_BINSHPOSIX to accompany MKSH_BINSHREDUCED
• Sync lksh manpage precisely
2013-05-02 20:21:45 +00:00
tg 55e9ca460c start next development iteration 2013-04-27 18:12:39 +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 5571430281 now get rid of the run-time check, the idivwrapv nonsense, and straighten out lksh 2013-04-26 19:40:09 +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 d99e470a64 bump 2013-03-05 15:41:41 +00:00
tg 817aeb8fdb both mksh(1) and POSIX say: "$@" should always generate multiple words
issue in pdksh reported in IRC by engla, thanks!
2013-02-23 20:03:31 +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 dffb1ab915 put list of check_categories into Makefrag.inc generated; bump patchlevel 2013-02-18 22:55:40 +00:00
tg e141cab1ac revert cid 10050DD0C8519194AE9 and 100511FC81525949AF7
AT&T SVR4 broke 'cc -c -o foo.o foo.c' totally

switch to an alternative method of finding out the prototypes
provided in IRC by dalias (thanks); RT says this fixes his
issues on SVR4 – let’s just ignore the ominous message from
cid 1004713D70A5362BACF about needing to be a compile-time
check unless something else pops up, I can’t think of something
that isn’t already covered
2013-02-17 07:06:15 +00:00
tg b684a7c6bd backpedal with $'…' and $"…" interpolation
it turns out this breaks more legacy scripts than anticipated
2013-02-17 05:40:17 +00:00
tg 47f8a21e3c SVR4 cc doesn’t like -c -o conftest.o when conftest.o already exists:
it errors out with “-o would overwrite conftest.o” (thanks RT for reporting)
2013-02-16 17:55:51 +00:00
tg 85d7059c48 … I fsck’d up and built R42b from MAIN ipv mksh-R42stable… oh well.
TODO: convert enum to something like uint8_t to save even more space
2013-02-16 00:21:57 +00:00
tg 6b797a7bc8 • test.sh now is -v (verbose) by default, new option -Q to quieten (like Build.sh)
• test.sh handles +P, +Q, +S, +v properly
2013-02-11 16:27:56 +00:00
tg 42e1bdc095 doc update 2013-02-10 21:20:57 +00:00
tg 43a41932e7 make DEBUG_LEAKS safely free all resources before the main shell exits 2013-02-10 18:17:30 +00:00
tg b23d768a9b Unbreak linking on AIX, reported (with fix) by Torsten Sillke, 10x! 2013-01-12 02:25:01 +00:00
tg 72a748c891 if you have to look *this* up, danger ahead; point to porter's info 2013-01-01 21:19:36 +00:00
tg 0ce1ca41cb carefully begin owcc (Watcom C’s POSIX cc wrapper) support 2012-12-28 04:58:13 +00:00
tg 113db497ba RT says QNX 4 has _SIGMAX not SIGMAX or NSIG 2012-12-28 03:35:34 +00:00
tg 192ea7638b now that we found out the root case for the recent QNX problem…
03:11⎜«RT|AO:#!/bin/mksh» YES it WORKS now!
… there’s no reason for sys_nerr to not be const, either ☺
2012-12-28 03:20:35 +00:00
tg f7acd1f3fc AIEEE!
03:00⎜«RT|AO:#!/bin/mksh» cc -c -o a.out does not output a.out but conftest.o (!!)
evil… just use tcfn=conftest.o for now, cf. cid 1004713D70A5362BACF (but why must it be one?)
2012-12-28 03:05:17 +00:00
tg b2396677e7 harmonise sys_{sig,err}list ⓐ checks, ⓑ uses, ⓒ _decl values when not needed, ⓓ prototypes; ⓔ “const” is a keyword and thus space-separated from the preceding ‘*’ pointer indicator 2012-12-28 02:28:39 +00:00
tg 64eddba65f -D__EXT_UNIX_MISC needed for “extern const char * const sys_errlist[];” on QNX 2012-12-27 15:52:47 +00:00
tg f998054508 16:39⎜«RT|Chatzilla:#!/bin/mksh» ok, tested cc -E outputs preprocessed out with leading space(!).
16:49⎜<mirabilos:#!/bin/mksh> that's like NeXTstep which insers spaces around =
16:49⎜<mirabilos:#!/bin/mksh> but we can sed that away I guess.
16:49⎜«RT|Chatzilla:#!/bin/mksh» yeah, modifying grep/sed lines adding " *" works
2012-12-24 17:50:10 +00:00
tg 6d5e27a31a gcc-snapshot (see below) issued a clobber warning, and both it and mgcc
yowled about the memmove test until I found a compromise
gcc version 4.8.0 20121120 (experimental) [trunk revision 193662] (Debian 20121120-1)
2012-12-22 00:03:42 +00:00
tg 8e6fa9a5c6 now we can actually prefer sys_errlist[] (oh, and _sys_errlist[] also exists, a̲n̲d̲ fix a pasto) over strerror(3) like we do for sys_siglist[] and strsignal(3); our implementation is smaller and does more code reuse than even MirBSD libc’s after all 2012-12-17 23:31:30 +00:00
tg 12c662b6e2 thanks to ISC (Interactive) Unix, we now know a few samples of errnos
that get used, plus one for the realpath-1 regression test; also make
sys_siglist_decl detection nicer and poison strerror() with non-const
return value ifdef DEBUG, make it always const
2012-12-17 23:18:11 +00:00
tg ae1ec32dbc fix whitespace; ACK RT’s Minix-vmd stmts 2012-12-17 22:57:50 +00:00
tg 4c5d7094ef RT also said what was missing on SunOS 4.1.1 (it also needs -DMKSH_UNEMPLOYED?) 2012-12-17 22:14:27 +00:00
tg b8d3f12025 merge/genericise RT’s port to Minix-vmd 2012-12-17 21:55:06 +00:00