Commit Graph

277 Commits

Author SHA1 Message Date
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 62e27c3e07 simplify print_columns func argument: no need to return the first arg any more 2015-07-05 14:43:08 +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 7f48503c66 sometimes, I feel pretty stupid
separate the backslash+newline things out of the *.opt files,
logically not 100% clean, but better as it is not generated
content anyway (keeping the one-liners in there for now, even
though more consistent would be shifting them out as well)
2015-05-01 23:16:31 +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 c3efd2abb2 use already-existing ksh_isdash helper macro 2015-04-29 18:32:44 +00:00
tg 94acf49453 a bit review-inspired getn/bi_getn review 2015-04-19 14:40:23 +00:00
tg 3c5c5d02fd fix IFS='\' issues, found by edualbus (Eduardo A. Bustamante López <dualbus@gmail.com>) 2015-04-11 21:18:47 +00:00
tg 5c5fb404b1 fix “read -n-1”, which still returns once the first read() succeeds
(it’s not identical to “read -N-1”!)
2015-03-20 21:01:41 +00:00
tg fcc59eee48 remove some unused string pooling stuff 2015-03-08 21:30:22 +00:00
tg e49d7bc3c6 better 2015-01-04 21:08:10 +00:00
tg a56f5ccbc4 fix mksh regression: empty line after “whence -v” with not found
spotted by Ypnose via IRC
2015-01-04 20:37:59 +00:00
tg 5650b03590 OpenBSD RCSID merge, and logical follow one change:
handle unknown bases as ksh93 does: larger downgrade to 10
(although our max will stay 36, as ksh93 doesn’t have upper/lowecase)
and smaller downgrade for typeset -i, but not for arithmetics
2014-12-15 23:18:47 +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 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 4c6e9269b9 mksh R50b 2014-09-03 19:55: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 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 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 2f6fa6fb3d revert unfinished change (listed in mksh.hts) 2014-01-05 19:20:31 +00:00
tg 2f7eec765d merge oksh’s “ctype cleanups” commit
(not much of it applies since we don’t use the OS’ table-based lookup)
2014-01-05 19:11:46 +00:00
tg 6217904193 detect getsid(2), also spotted by RT, this on MSYS 2013-11-30 17:41:35 +00:00
tg c4c4fd7365 RCSID-only oksh sync (their whitespace changes don’t apply to us)
note that emacs.c partial peereboom rewrite is *not* merged, and kept that way
2013-11-30 17:33:51 +00:00
tg d1245ee13a more clueful (automatic) getopt string generation 2013-11-17 22:21:18 +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 61886de5ee oksh sync (RCSID only) 2013-11-17 22:19:42 +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
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 14667a9838 int → bool; commit as a TODO comment a begun change attempt 2013-09-10 16:30:50 +00:00
tg bb4083d649 use ‘z’ shf printf modifier for out-of-memory message, now that we have it 2013-06-03 22:28:33 +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 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 fa0d9fc499 rcsid-only sync with oksh, dropping this functionality:
• mail.c was removed anyway
• we do not use “long long” in mksh, since it’s not in ANSI C89

instead, we probably need some 64-bit ops in the long run, but we can
use some host types (might want to use time_t for tv_sec, but we cannot
print that yet); might need to handle them in some generic manner…
2013-04-26 17:39:30 +00:00
tg fc2ec318c1 use nicer (and same as in other places!) error message for typeset 2013-03-30 15:39:36 +00:00
tg 94dfda0be0 RCSID sync w/ oksh; whitespace (KNF) 2013-03-24 21:34:14 +00:00
tg 0a3fe06229 another MidnightBSD /bin/sh kludge: classic BSD echo 2013-02-18 22:47:32 +00:00
tg 744f77c668 fix running the ERR and EXIT traps in case of set -e and/or eval (includes Debian #696823) 2013-01-01 20:45:04 +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 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 006d2c3c02 __CRAZY=Yes clean wants switch(enum) to be complete 2012-12-17 23:09:15 +00:00
tg 0780070d24 add a few assertions for LLVM+Clang 3.2 scan-build; no !DEBUG changes 2012-12-08 18:30:31 +00:00
tg cf807eb83a Add assertions and shuffle code around for LLVM+Clang scan-build. 2012-12-04 01:18:34 +00:00
tg b868c517b7 remove *all* nonnull assertions and other workarounds for clang scan-build
this beast evolved in the last 2½ years, and we’ve had trouble with
some of them earlier
2012-12-01 01:36:30 +00:00
tg 8caee45c60 int → bool 2012-10-30 20:13:20 +00:00
tg f5ccc2feb3 while we do not condone killing of cats, fix LP#1058815 2012-10-30 20:06:49 +00:00
tg c7419d9e6a defer setting exstat for eval to 0 (the one used in case shell() is empty)
until after the stuff run in shell() has had a chance to toy with $?

bug forwarded by one of our packagers, found by one of their users
2012-10-21 21:55:05 +00:00