Commit Graph

3531 Commits

Author SHA1 Message Date
kre
3c2922e71c Properly support EDITRC - use it as (naming) the file when setting
up libedit, and re-do the config whenever EDITRC is set.
2017-06-27 02:22:08 +00:00
kre
a3be5e86c2 Make arg parsing in kill POSIX compatible with POSIX (XBD 2.12) by
parsing the way getopt(3) would, if only it could handle the (required)
-signumber and -signame options.  This adds two "features" to kill,
-ssigname and -lstatus now work (ie: one word with all of the '-', the
option letter, and its value) and "--" also now works (kill -- -pid1 pid2
will not attempt to send the pid1 signal to pid2, but rather SIGTERM
to the pid1 process group and pid2).  It is still the case that (apart
from --) at most 1 option is permitted (-l, -s, -signame, or -signumber.)

Note that we now have an ambiguity, -sname might mean "-s name" or
send the signal "sname" - if one of those turns out to be valid, that
will be accepted, otherwise the error message will indicate that "sname"
is not a valid signal name, not that "name" is not.   Keeping the "-s"
and signal name as separate words avoids this issue.

Also caution: should someone be weird enough to define a new signal
name (as in the part after SIG) which is almost the same name as an
existing name that starts with 'S' by adding an extra 'S' prepended
(eg: adding a SIGSSYS) then the ambiguity problem becomes much worse.
In that case "kill -ssys" will be resolved in favour of the "-s"
flag being used (the more modern syntax) and would send a SIGSYS, rather
that a SIGSSYS.    So don't do that.

While here, switch to using signalname(3) (bye bye NSIG, et. al.), add
some constipation, and show a little pride in formatting the signal names
for "kill -l" (and in the usage when appropriate -- same routine.)   Respect
COLUMNS (POSIX XBD 8.3) as primary specification of the width (terminal width,
not number of columns to print) for kill -l, a very small value for COLUMNS
will cause kill -l output to list signals one per line, a very large
value will cause them all to be listed on one line.) (eg: "COLUMNS=1 kill -l")

TODO: the signal printing for "trap -l" and that for "kill -l"
should be switched to use a common routine (for the sh builtin versions.)

All changes of relevance here are to bin/kill - the (minor) changes to bin/sh
are only to properly expose the builtin version of getenv(3) so the builtin
version of kill can use it (ie: make its prototype available.)
2017-06-26 22:09:16 +00:00
christos
57d721417b source .editrc after we initialize so that commands persist! 2017-06-26 20:28:01 +00:00
kre
7f75cc46b5 Another ancient (highly improbable) bug bites the dust. This one
caused by incorrect macro usage (ie: using the wrong one) which has
been in the sources since version 1.1 (ie: forever).

Like the previous (STACKSTRNUL) bug, the probability of this one
actually occurring has been infinitesimal but the LINENO code increases
that to infinitesimal and a smidgen... (or a few, depending upon usage).

Still, apparently that was enough, Kamil Rytarowski discovered that the
zsh configure script (damn competition!) managed to trigger this problem.
2017-06-24 11:23:35 +00:00
kamil
c6c3f8f1f5 ksh: Drop support for systems without clock_t type 2017-06-23 00:35:20 +00:00
kamil
b831372d44 ksh: Replace homegrown int_least32_t with the C99 version 2017-06-23 00:29:42 +00:00
kamil
730f723665 ksh: Drop support for systems that return void for closedir(2) 2017-06-23 00:20:22 +00:00
kamil
acc2fa794c ksh: Use ANSI C varargs, drop support for older version <varargs.h> 2017-06-23 00:18:01 +00:00
kamil
cb1c866326 ksh: Remove remnant hack for SCO UNIX in tty code 2017-06-23 00:11:01 +00:00
kamil
a761aa7e3f ksh: Remove support for NeXT Operating System 2017-06-23 00:09:36 +00:00
kamil
0e8072bdff ksh: Drop the latest ifdef for BSD4.1 and eliminate dead code around it 2017-06-23 00:07:15 +00:00
kamil
c65b0df2e9 ksh: Drop BSD4.3 temporary hack in tty code 2017-06-23 00:04:20 +00:00
kamil
14ae4d8526 ksh: Drop support for UNIX V7-style signal routines 2017-06-23 00:00:58 +00:00
kamil
0a9965d29a ksh: Drop fallback for BSD4.2 signal routines 2017-06-22 23:59:28 +00:00
kamil
53e78cf286 ksh: Remove fallback to BSD4.1 signal routines 2017-06-22 23:56:24 +00:00
kamil
3b7ff6c991 ksh: Drop support for systems without mmap(2) 2017-06-22 23:54:13 +00:00
kamil
52b3355e26 ksh: Drop support for systems without dup2(2) 2017-06-22 23:50:24 +00:00
kamil
237b342911 ksh: Drop support for ISC UNIX 2017-06-22 23:47:29 +00:00
kamil
eed5a31e9b ksh: Drop support for systems without offsetof(3) 2017-06-22 23:42:35 +00:00
kamil
bdcebfe8f5 ksh: Drop support for systems without <limits.h> 2017-06-22 23:38:49 +00:00
kamil
accac1300c ksh: Drop support for systems without <fcntl.h> 2017-06-22 23:37:00 +00:00
kamil
fb30a30908 ksh: Drop support for systems without memmove(3) and stop using bcopy(3) 2017-06-22 23:33:36 +00:00
kamil
99f9f7cfb5 ksh: Drop support for systems without memset(3) 2017-06-22 23:30:42 +00:00
kamil
98fef8f2dd ksh: Drop usage of SVID header <memory.h>, it's legacy standard 2017-06-22 23:29:35 +00:00
kamil
00f99741e1 ksh: Drop support for systems without strcasecmp(3) and strncasecmp(3) 2017-06-22 23:27:53 +00:00
kamil
05a5edb66a ksh: Drop support for systems without strstr(3) 2017-06-22 23:26:17 +00:00
kamil
8f43bfe473 ksh: Drop support for systems without <string.h> 2017-06-22 23:23:27 +00:00
kamil
ba6c50ffa7 ksh: Drop support for systems without <stddef.h>
No functional change.
2017-06-22 23:19:53 +00:00
kamil
6f9fbdf520 ksh: Drop support for systems without <stdlib.h>
No functional change.
2017-06-22 23:17:50 +00:00
kamil
17e1427bb7 ksh: Drop support for systems without <unistd.h>
This code wouldn't work for them anyway.

No functional change.
2017-06-22 23:15:05 +00:00
kamil
b42d86bc68 ksh: Kill switch for CLOSEDIR_VOID (closedir(2) returns void)
No users in the code. No functional change.
2017-06-22 23:11:48 +00:00
kamil
9d04c96c0d ksh: Assume that $CC handles const (ANSI C89)
No functional change.
2017-06-22 23:09:32 +00:00
kamil
af6175f2e1 Drop support for $CC incapable to use void* / volatile* (pre ANSI C89) 2017-06-22 19:46:54 +00:00
kamil
d6fe16556c Drop Ultrix support from ksh(1), a DEC UNIX for VAX 2017-06-22 19:41:07 +00:00
kamil
eb13ce8ce3 Reapply removal of code from 90ties for OS/2 Cygwin AIX HPUX SCOUnix
Added missing #endif terminator in emacs.c
2017-06-22 14:20:46 +00:00
kamil
266bea007e Temporarily revert previous.
emacs.* gets wrong code in generation
2017-06-22 14:11:27 +00:00
kamil
ffa8eeb219 Remove code for AIX, including hack for 3.2.5 (from 1997) - from ksh(1)
OK by <kre>
2017-06-22 13:37:16 +00:00
kamil
2f8869f916 Drop HP-UX support from ksh(1)
OK by <kre>
2017-06-22 13:35:47 +00:00
kamil
4ae20c97a6 Remove sco unix 3.2v4.1 support (from 1992) from ksh(1)
OK by <kre>
2017-06-22 13:34:48 +00:00
kamil
e5604d4f02 Remove os2 support in ksh(1)
OK by <kre>
2017-06-22 13:33:39 +00:00
kamil
fc74b4892d Remove ancient cygwin support in ksh(1)
OK by <kre>
2017-06-22 13:32:04 +00:00
kre
467f8e2cd3 It is amazing what nonsense appears to work sometimes... (all my nonsense too!)
Two bugs here, one benign because of the way the script is used.
The other hidden by NetBSD's sort being stable, and the data not really
requiring sorting at all...

So as it happens these fixes change nothing, but they are needed anyway.

(The contents of the generated file are only used in DEBUG shells, so
this is really even less important than it seems.)
2017-06-19 11:55:07 +00:00
kre
87d90665d5 Another fix from FreeBSD (this one from April 2009).
When processing a string (as in eval, trap, or sh -c) don't allow
trailing \n's to destroy the exit status of the last command executed.

That is:
	sh -c 'false

	'
	echo $?
should produce 1, not 0.
2017-06-19 03:21:31 +00:00
kre
3892a5b005 Fix from FreeBSD (applied there in July 2008...)
Don't dump core with input like sh -c 'x=; echo >&$x' - that is where
the word after a >& or <& redirect expands to nothing at all.
2017-06-19 02:51:51 +00:00
kre
d8ae0af5de Correct the initial line number used for processing -c arg strings.
(It was inheriting the value from end of profile file processing) - I didn't
notice before as I usually test with empty or no profile files to avoid
complications.   Trivial change which should have very limited impact.
2017-06-19 02:49:33 +00:00
kre
701ac13230 Now that excessive use of STACKSTRNUL has served its purpose (well, accidental
purpose) in exposing the bug in its implementation, go back to not using
it when not needed for DEBUG TRACE purposes.   This change should have no
practical effect on either a DEBUG shell (where the STACKSTRNUL() calls
remain) or a non DEBUG shell where they are not needed.
2017-06-19 02:46:50 +00:00
kre
bbd0083b9e "b" more forgiving when sorting options to allow reasonable (and intended)
flexibility in option.list format.   Changes nothing for current option.list.
2017-06-19 02:43:55 +00:00
kre
f72bc19e74 NFC: DEBUG mode only change. Fix botched cleanup of one TRACE(). 2017-06-18 07:50:46 +00:00
kre
765053c5be NFC: DEBUG related comment change - catch up with reality. 2017-06-17 12:41:20 +00:00
kre
0ed8885aea NFC - DEBUG mode only change - complete a change made earlier (marking
the line number when included in the trace line tag to show whether it
comes from the parser, or the elsewhere as they tend to be quite different).
Initially only one case was changed, while I pondered whether I liked it
or not.  Now it is all done...   Also when there is a line tag at all,
always include the root/sub-shell indicator character, not only when the
pid is included.
2017-06-17 12:16:16 +00:00