Commit Graph

3576 Commits

Author SHA1 Message Date
kre
cdfea65894 Fix a reference after free (and consequent nonsense diagnostic for
attempts to set readonly variables) I added in 1.60 by incompletely
copying the FreeBSD fix for the lost memory issue.
2017-07-12 19:06:16 +00:00
kre
2eafa75298 DEBUG only changes. Convert the TRACE() calls in the remaining files
that still used it to the new format.   NFC.
2017-07-05 20:00:27 +00:00
kre
9006b74112 DEBUG changes: convert DEBUG TRACE() calls to new format.
ALso, cause exec failures to always cause the shell to exit with
status 126 or 127, whatever the cause.  127 is intended for lookup
failures (and is used that way), 126 is used for anything else that
goes wrong (as in several other shells.)  We no longer use 2 (more easily
confused with an exit status of the command exec'd) for shell exec failures.
2017-07-05 19:58:10 +00:00
kre
ae375f0127 Mostly DEBUG and white space changes. Convert DEEBUG TRACE() calls to
the new format.   Also #if 0 a function definition that is used nowhere.
While here, change the function of pushfile() slightly - it now sets
the buf pointer in the top (new) input descriptor to NULL, instead of
simply leaving it - code that needs a buffer always (before and after)
must malloc() one and assign it after the call.  But code which does not
(which will be reading from a string or similar) now does not have to
explicitly set it to NULL (cleaner interface.)   NFC intended (or observed.)
2017-07-05 19:54:21 +00:00
kre
2e1a04e9a7 DEBUG and white space changes only. Convert TRACE() calls for DEBUg mode
to the new style.   NFC (when not debugging sh).
2017-07-05 19:47:11 +00:00
wiz
ee3d656c82 Use Ex. 2017-07-04 06:50:04 +00:00
wiz
285e86b675 Use Ex. Remove superfluous Pp. 2017-07-04 06:49:35 +00:00
wiz
39b251a71c Use Ex. 2017-07-04 06:46:51 +00:00
wiz
01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
kre
a64e63ed28 Do a better job of detecting the error in pkgsrc/devel/libbson-1.6.3's
configure script, ie: $(( which is intended to be a sub-shell in a
command substitution, but is an arith subst instead, it needs to be
written $( ( to do as intended.   Instead of just blindly carrying on to
find the missing )) somewhere, anywhere, give up as soon as we have seen
an unbalanced ')' that isn't immediately followed by another ')' which
in a valid arith subst it always would be.

While here, there has been a comment in the code for quite a while noting a
difference in the standard between the text descr & grammar when it comes to
the syntax of case statements.   Add more comments to explain why parsing it
as we do is in fact definitely the correct way (ie: the grammar wins arguments
like this...).
2017-07-03 20:16:44 +00:00
joerg
da656e3d1c Kill enough K&R cruft to build with clang again. 2017-07-01 23:12:08 +00:00
kre
2ff69d1b74 Make $- list flags in the same order they appear in sh(1) 2017-07-01 06:14:51 +00:00
wiz
ea9a6a6434 Sort options (our default is 0..9AaBbZz).
Fix markup problems and a typo.
2017-07-01 05:11:57 +00:00
kre
8d40ff9951 Correct a markup typo (why did I not see this before the prev commit??) 2017-06-30 23:48:50 +00:00
kre
3b0318c107 Omnibus manual update for prompt expansions and new variables. Throw in
some random cleanups as a bonus.
2017-06-30 23:07:29 +00:00
kre
dc83385122 Implement a bunch of new shell environment variables. many mostly useful
in prompts when expanded at prompt time, but all available for general use.
Many of the new ones are not available in SMALL shells (they work as normal
if assigned, but the shell does not set or use them - and there is no magic
in a SMALL shell (usually for install media.))
2017-06-30 23:05:45 +00:00
kre
1fca9bbf62 Implement PS1, PS2 and PS4 expansions (variable expansions, arithmetic
expansions, and if enabled by the promptcmds option, command substitutions.)
2017-06-30 23:02:56 +00:00
kre
3b297678bf Include redirections in trace output from "set -x" 2017-06-30 23:01:21 +00:00
kre
19986c5f4a NFC: DEBUG only change - provide an externally visible (to the DEBUG sh
internals) interface to one of the internal (private to trace code) functions
2017-06-30 23:00:40 +00:00
kamil
6327936549 ksh: Eliminate dead function x_complete_word() 2017-06-30 05:18:36 +00:00
kamil
dda96fab20 ksh: Eliminate dead code from expand.h 2017-06-30 05:14:12 +00:00
kamil
00cd1c66a2 ksh: Drop old hack for FreeBSD 1.1.5 and CLK_TCK 2017-06-30 04:44:46 +00:00
kamil
dd8a75d57f ksh: Upgrade to C99 <stdbool.h>
This shell already used C99 functions.
2017-06-30 04:41:19 +00:00
kamil
c2a517fe40 ksh: Eliminate dead MEM_DEBUG sections, there is missing code for it
MEM_DEBUG used to contain malloc(3) debugging facilities.
2017-06-30 04:30:26 +00:00
kamil
a5a27bbf6f ksh: Drop support for OSes without POSIX sigaction(2) 2017-06-30 04:22:22 +00:00
kamil
2537c199ea ksh: Drop support for OSes that don't map /dev/fd 2017-06-30 04:11:57 +00:00
kamil
91e15fa768 ksh: Drop old hack fo SunOS 4.1.x (1990-1994) 2017-06-30 04:01:48 +00:00
kamil
fac4b39487 ksh: Drop support for systems without <sys/stat.h>
In future the order of includes will be normalized with KNF.

No functional change intended.
2017-06-30 03:56:12 +00:00
kamil
1dacfa0dd2 ksh: Drop support for systems with broken <sys/time.h> / <time.h> 2017-06-30 03:43:57 +00:00
kamil
e6ed5dea98 ksh: Drop support for systems without POSIX lstat(2) 2017-06-30 03:35:16 +00:00
kamil
a396fc9936 ksh: Drop support for systems without POSIX <sys/wait.h> 2017-06-30 03:32:28 +00:00
kamil
3e5f067b68 ksh: Drop support for systems with broken times(3)
This fallback code wouldn't work anyway.

times(3) is an obsolete interface by getrusage(2) and gettimeofday(2).
In future it will be swiched to more modern interfaces.

No functional change intended.
2017-06-30 03:23:18 +00:00
kamil
2c22621e8f ksh: Assume ANSI C prototypes 2017-06-30 02:51:14 +00:00
kamil
81c962c859 ksh: Drop support for systems without functional waitpid(2) 2017-06-30 02:38:09 +00:00
kamil
8ea5ae4cd1 ksh: Drop support for systems without POSIX signal routines 2017-06-30 02:20:47 +00:00
kamil
306d025987 ksh: Drop support for systems without implementation of EINTR
These systems weren't handled anyway.
2017-06-30 02:13:29 +00:00
kamil
51ebc97c9d ksh: Drop support for systems without handling shebang 2017-06-30 02:06:59 +00:00
kamil
5c93126131 ksh: Drop support for OSes without POSIX types
Assume available: mode_t, off_t, pid_t, uid_t, rlim_t, sigset_t.
2017-06-30 02:02:41 +00:00
kamil
9d5663e055 ksh: Drop support for systems without <sys/wait.h> 2017-06-30 01:56:34 +00:00
kamil
3e63fce1f9 ksh: Drop ksh_wait.h that reinvents <sys/wait.h> (POSIX header)
Switch jobs.c to <sys/wait.h>.

No functional change intended.
2017-06-30 01:52:34 +00:00
kamil
d0aa393796 ksh: Drop support for systems without gid_t 2017-06-30 01:36:30 +00:00
kre
4754b1e8f4 Now libedit supports embedded mode switch sequence, improve sh
support for them (adds PSlit variable to set the magic character).
2017-06-28 13:46:06 +00:00
christos
650f73e320 Add literal prompt support this allows one to do:
CA="$(printf '\1')"
PS1="${CA}$(tput bold)${CA}\$${CA}$(tput sgr0)${CA} "
2017-06-27 23:27:03 +00:00
kre
8ca5565bc1 Make one example more like a real world possibility (it still isn't, but
is closer) - though the actual content is irrelevant to the point being made.
2017-06-27 12:43:44 +00:00
wiz
30b9dfc881 Get rid of workarounds for ancient groff html backend.
Simplify macro usage.
2017-06-27 08:30:40 +00:00
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