246 Commits

Author SHA1 Message Date
tg
719778193a add missing colon to two error msgs (no effect on dedup) 2015-09-05 17:20:19 +00:00
KO Myung-Hun
4c61aeebe5 Use upstream style macro/function names
modified:   edit.c
    modified:   eval.c
    modified:   exec.c
    modified:   main.c
    modified:   misc.c
    modified:   sh.h
2015-07-21 16:30:47 +09:00
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
ba8a6e9461 merge OS/2 style PATH (absolute with drive letters, ‘;’ as separator)
From: KO Myung-Hun <komh@chollian.net>
2015-07-10 19:36:38 +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
dcd8b6389b apply the new cat hack to printf, too, to prefer it over the builtin 2015-07-09 20:20: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
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
tg
62e27c3e07 simplify print_columns func argument: no need to return the first arg any more 2015-07-05 14:43:08 +00:00
KO Myung-Hun
01648d4495 scriptexec: cosmetic 2015-06-11 22:44:00 +09:00
KO Myung-Hun
df2cf83f8b scriptexec: preserve original shell/interpreter path
For example,

When failing to execute the script which starts with the above line,
an error message does not contain information for /path/to/name.
Instead, it contains only name. In addition, if /path/to/dir/, an error
message contains empty string for a name of a failed script.
2015-06-11 22:16:17 +09:00
KO Myung-Hun
b27e10a32e scriptexec: try to use shell/interpreter name as well on OS/2
If specified path does not exist, try to use shell/interpreter name
without directory.

On OS/2, directory structures of distribution is quite different. And
Some scripts have hard coded shell/interpreter. To overcome this, allow
to use shell/interpreter name if specified path does not exist.
2015-06-11 16:16:07 +09:00
KO Myung-Hun
89324074c4 Prepend /@unixroot to rooted paths on OS/2
$UNIXROOT is a root directory of FHS on OS/2. /@unixroot is replaced by
$UNIXROOT at runtime.
2015-06-03 13:00:49 +09:00
KO Myung-Hun
a32d1d70bf Support .cmd and .bat on OS/2 2015-06-03 13:00:44 +09:00
KO Myung-Hun
148c019595 MZ magic is supported on OS/2 2015-06-03 13:00:44 +09:00
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
9b30ce1a6d Support extproc on OS/2
extproc is similar to like #! on OS/2.
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
a3fdbc6802 Make all the files executable on OS/2
On OS/2, an executable status is determined by an extension such as .exe
not real executable mode.

Script files without executable extensions such as .exe, cannot be
executed.
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
tg
c3efd2abb2 use already-existing ksh_isdash helper macro 2015-04-29 18:32:44 +00:00
tg
b7332de28c a bit oksh-inspired getn return value checking, plus some code optimisation 2015-04-19 14:40:09 +00:00
tg
a1ba509bb9 oksh RCSID sync: we use mksh getn() instead of OS strtonum() which is just as safe (audited right now) 2015-04-19 14:23:26 +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
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
1248a0a521 basically unbreak use of $*/$@ in here documents
a bit funny:
with NUL IFS, $* behaves like dash ('ab') and $@ like bash/ksh93 ('a b')

with WS or NWS IFS, all shells behave alike though
2015-02-19 22:00:03 +00:00
tg
ab683420df fix use of $*/$@ in scalar context in [[ … ]] and case; spotted by Stéphane Chazelas 2015-02-19 21:58:19 +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
b94b2e363a stop (ab)using the OS symbolic constant EOF, always use -1; plus misc fixes 2015-02-06 10:09:07 +00:00
tg
f235766a3d int → bool 2015-02-06 09:42:46 +00:00
tg
3be80b75ed remove dead code: this can no longer happen since exec.c,v 1.67 2015-02-06 09:42:08 +00:00
tg
2f26836ed1 fix shebang/magic decoding 2014-11-25 22:46:58 +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
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
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
49c2e7a999 fix size calculations; prefer memleak over segfault; see LP#1380389 for more 2014-10-12 20:32:09 +00:00
tg
4afe543fa0 fix x+=<< 2014-10-12 19:55:01 +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
c7774ae861 Detect (potentially mismatched) ELF files; suggested by enh@google.com 2014-06-24 18:38:31 +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
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
c1c0b997fe make the code to exec simple commands also available for mksh_small 2014-01-11 16:26:28 +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
f920d94785 add O_BINARY to all open() calls except tty_fd
cf. http://svn.netlabs.org/libc/wiki/Faq#Whydoesntreadfdbufsize_of_filereturnsize_of_file
2013-10-09 11:59:30 +00:00