Commit Graph

318 Commits

Author SHA1 Message Date
tg 3aac3c30b5 return 128+SIGALRM if read with timeout timeouts, inspired by GNU bash 2016-11-11 22:17:09 +00:00
tg 6267ea36a4 fix print -cn 2016-11-11 21:37:35 +00:00
tg 6c04e4a665 make print -c honour line separator 2016-11-11 21:13:25 +00:00
tg 26689a7c81 just 'print -c' outputs not even a newline; plug a memleak while here 2016-11-11 20:53:15 +00:00
tg 5ba6be5837 put print_columns options into a helper struct, eases passing things around 2016-11-11 20:14:18 +00:00
tg e16b0b9d5b first implementation of “print -c” for columnising, currently hardcoded newlines 2016-11-11 19:59:39 +00:00
tg 6a9dae2144 implement print -N: set output word and line separator to NUL 2016-11-11 19:18:40 +00:00
tg 8c2eda2f0f implement print -l: change output word separator to newline 2016-11-11 19:12:52 +00:00
tg d4b81df050 goto keeps us from evaluating the loop condition twice in immediate succession
(and shaves off an indentation level)
2016-11-11 19:09:44 +00:00
tg 1c07e75fc0 implement: empty arg in print -A is input word separator 2016-11-11 19:02:26 +00:00
tg 4ed09871a9 refactor c_print into a loop 2016-11-11 18:50:09 +00:00
tg 4e855b1be2 pack local bools into a struct, for tighter stack packing 2016-11-11 18:44:32 +00:00
tg 61969809e4 read(2) and write(2) don’t EINTR for fast input (LP#1616692) 2016-08-25 16:21:14 +00:00
tg 757e25fb21 implement $KSH_MATCH and, to make it usable, ${foo@/bar/baz};
add a real-life example (for slagtc’s programmable tab completion)
to the manpage
2016-08-01 21:38:07 +00:00
tg 5c8f42c841 fix missing Xcheck leading to overflow for strings > 127 array elements 2016-08-01 14:23:24 +00:00
tg f21d6a3ffd fix (POSIX) errorlevel of ‘.’ when sourced file has no commands; issue discovered by Natureshadow 2016-07-28 21:39:19 +00:00
tg dd281c52ec defer to external rename(1) too 2016-07-26 21:50:46 +00:00
tg 54a8067fd2 add print -A for R53 2016-07-25 20:38:04 +00:00
tg c3e794c4d0 rework string pooling; disable our own (rely on compiler’s)…
• if HAVE_STRING_POOLING is set to 1
• if HAVE_STRING_POOLING is set to 2 and not GCC < 4 is used
• if HAVE_STRING_POOLING is not set to 0 and LLVM or GCC >= 4 is used

Closes: LP#1580348
2016-07-25 00:04:48 +00:00
tg 816614d3ce re-add realpath to prefer-external-if-argument, needed by Debian 2016-07-24 23:11:51 +00:00
tg e8bbf79d8c invent builtin flags instead of special-casing cat and printf for prefer-external-over-builtin stuff 2016-07-24 23:10:04 +00:00
tg 582e745958 since we already support XSI test -a/-o, they better behave 2016-06-26 00:44:25 +00:00
tg 1563b70658 abort read builtin in case of read(2) errors
noticed by arekm, persuaded by jilles, compared with other equivalent
pieces of code reading in mksh
2016-06-25 23:52:46 +00:00
tg 3b5f9c744c I didn’t like the code behind command -[Vv] and whence, so I rewrote it.
Bugreport by Martijn Dekker <martijn@inlv.org> about POSIX non-compliance
2016-02-26 20:56:45 +00:00
tg 188691d285 save 200 bytes off .text by revisiting string pooling
also, forgotten version bump
2016-01-21 18:24:45 +00:00
tg 61f7661b92 fix errno in print/echo builtin; optimise (with partial rewrite) 2016-01-20 21:34:13 +00:00
tg 9167be0584 handle SIGPIPE in built-in cat correctly (LP#1532621) 2016-01-20 20:29:48 +00:00
tg 046d8e5b7a align with future POSIX on http://austingroupbugs.net/view.php?id=351
with accepted interpretation (*sigh*); merge VARASN|ARRAYVAR→CMDASN
2016-01-19 23:12:15 +00:00
tg 1b0e4f54cb permit 'read -A/-a arr[idx]' as long as only one element is read;
fix corruption of array indicēs with this construct (LP#1533396)
2016-01-14 22:49:33 +00:00
tg 2492c5692b incorporate suggestions by J�rg Schilling 2016-01-13 17:20:52 +00:00
tg 66ace7e647 fix regression introduced with test(1) rewrite in R40d:
evaluation errors were not returned any more

Bug spotted and patch by Martijn Dekker <martijn@inlv.org>
2015-12-12 19:27:36 +00:00
tg 7a47656efe fix \u0000 and \x00 being ignored in $'…' and print +r expansion 2015-10-24 19:46:10 +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 af35e9a6de revert most of commitid 3ec342c92b3a8874 and fixup the rest;
this should bring us closer to POSIX again
2015-10-09 17:48:53 +00:00
tg 3fc8b5eb94 partial oksh sync, up to commit 80be547da108d5c241ae068290ca3e331446aa41? 2015-10-09 16:11:19 +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 c674e71377 be more careful with signals and errorlevels; bounds-check them better;
don’t trust the OS as POSuX comes up with more-than-8-bit exit codes now;
also, one more int → bool
2015-08-13 21:38:19 +00:00
tg 9d30e9c9d6 oksh sync: one rcsid-only plus this one by guenther:
Zero-pad the seconds in the output of 'time' to make columns line up
2015-08-13 21:04:12 +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 950827394b more easy OS/2 fixes
From: KO Myung-Hun <komh@chollian.net>
2015-07-09 19:46:43 +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 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