mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
This commit makes three interrelated changes.
First, the code for erasing the command line before redrawing it
upon a window size change is simplified and modernised. Instead of
erasing the line with lots of spaces, it now uses the sequence
obtained from 'tput ed' (usually ESC, '[', 'J') to "erase to the
end of screen". This avoids messing up the detection and automatic
redrawing of wrapped lines on terminals such as Apple Terminal.app.
Second, the -b/--notify option is made more usable. When it is on
and either the vi or emacs/gmacs line editor is in use, 'Done' and
similar notifications are now buffered and trigger a command line
redraw as if the window size changed, and the redraw routine prints
that notify buffer between erasing and redrawing the commmnd line.
The effect is that the notification appears to magically insert
itself directly above the line you're typing. (The notification
behaviour when not in the shell line editor, e.g. while running
commands such as external editors, is unchanged.)
Third, a bug is fixed that caused -b/--notify to only report on one
job when more than one terminated at the same time. The rest was
reported on the next command line as if -b were not on. Reproducer:
$ set -b; sleep 1 & sleep 1 & sleep 1 &
This commit also includes a fair number of other window size and
$COLUMNS/$LINES handling tweaks that made all this easier, not all
of which are mentioned below.
src/cmd/ksh93/include/fault.h,
src/cmd/ksh93/sh/fault.c:
- Replace sh_update_columns_lines with a new sh_winsize() function.
It calls astwinsize() and is to be used instead of it, and
instead of nv_getval(LINES) and nv_getval(COLUMNS) calls. It:
- Allows passing one or neither of lines or cols pointers.
- Updates COLUMNS and LINES, but only if they actually changed
from the last values. This makes .set discipline functions
defined for these variables more useful.
- Sets the sh.winch flag, but only if COLUMNS changes. If only
the height changes, the command line does not need redrawing.
src/cmd/ksh93/include/io.h:
- Add sh_editor_active() that allows checking whether one of vi,
emacs or gmacs is active without onerous #if SHOPT_* directives.
src/cmd/ksh93/sh/jobs.c: job_reap():
- Remove the fix backported in fc655f1a
, which was really just a
workaround that papered over the real bug.
- Move a check for errno==ECHILD so it is only done when waitpid()
returns an error (pid < 0); the check was not correct because C
library functions that do not error out also do not change errno.
- Move the SH_NOTIFY && SH_TTYWAIT code section to within the
while(1) loop so it is run for each job, not only the
last-processed one. This fixes the bug where only one job was
notified when more than one ended at the same time.
- In that section, check if an editor is active; if so, set the
output file for job_list() to sh.notifybuffer instead of standard
error, list the jobs without the initial newline (JOB_NLFLAG),
and trigger a command line redraw by setting sh.winch.
src/cmd/ksh93/edit/edit.c:
- Obtain not just CURSOR_UP but also ERASE_EOS (renamed from
KILL_LINE) using 'tput'. The latter had the ANSI sequence
hardcoded. Define a couple of TPUT_* macros to make it easier to
deal with terminfo/termcap codes.
- Add get_tput() to make it easier to get several tput values
robustly (with SIGINT blocked, trace disabled, etc.)
- ed_crlf(): Removed. Going by those ancient #ifdefs, nothing that
93u+m will ever run on requires a '\r' before a '\n' to start a
new line on the terminal. Plus, as of 93u+, there were already
several spots in emacs.c and vi.c where it printed a sole '\n'.
- ed_read():
- Simplify/modernise command line erase using ERASE_EOS.
- Between erasing and redrawing, print the contents of the notify
buffer. This has the effect of inserting notifications above
the command line while the user is typing.
src/cmd/ksh93/features/cmds:
- To detect terminfo vs termcap codes, use all three codes we're
currently using. This matters on at least on my system (macOS
10.14.6) in which /usr/bin/tput has incomplete terminfo support
(no 'ed') but complete termcap support!
287 lines
12 KiB
Text
287 lines
12 KiB
Text
Announcing: KornShell 93u+m 1.0.0-beta.(unreleased)
|
|
https://github.com/ksh93/ksh
|
|
|
|
In May 2020, when every KornShell (ksh93) development project was
|
|
abandoned, development was rebooted in a new fork based on the last
|
|
stable AT&T version: ksh 93u+. This new fork is called ksh 93u+m as a
|
|
permanent nod to its origin. We're restarting it at version 1.0. Seven
|
|
months after the first beta, the second one is ready. Please test this
|
|
second beta and report any bugs you find, or help us fix known bugs.
|
|
|
|
We're now the default ksh93 in some OS distributions, at least Debian
|
|
and Slackware! Even though we don't think it's stable release quality
|
|
yet, the consensus seems to be that 93u+m is already much better than
|
|
the last AT&T release.
|
|
|
|
Main developers: Martijn Dekker, Johnothan King, hyenias
|
|
|
|
Contributors: Andy Fiddaman, Anuradha Weeraman, Chase, Gordon Woodhull,
|
|
Govind Kamat, Harald van Dijk, Lev Kujawski, Marc Wilson, Ryan Schmidt,
|
|
Sterling Jensen
|
|
|
|
HOW TO GET IT
|
|
|
|
Please download the source code tarball from our GitHub releases page:
|
|
|
|
https://github.com/ksh93/ksh/releases
|
|
|
|
To build, follow the instructions in README.md or src/cmd/ksh93/README.
|
|
|
|
HOW TO GET INVOLVED
|
|
|
|
To report a bug, please open an issue at our GitHub page (see above).
|
|
Alternatively, email me at martijn@inlv.org with your report.
|
|
To get involved in development, read the brief policy information in
|
|
README.md and then jump right in with a pull request or email a patch.
|
|
See the TODO file in the top-level directory for a to-do list.
|
|
|
|
### MAIN CHANGES between 1.0.0-beta.2 and 1.0.0-(unreleased) ###
|
|
|
|
New features in built-in commands:
|
|
|
|
- Two bash-like flags for 'whence' were backported from ksh 93v-:
|
|
- 'whence -P/type -P' is an alias to the existing -p flag.
|
|
- 'whence -t/type -t' will print only the type of a command in a simple
|
|
format that is designed to be easy to use for scripts. Example:
|
|
$ type -t typeset; whence -t sh
|
|
builtin
|
|
file
|
|
|
|
- Added three options to the ulimit builtin with the same names and
|
|
functionality as in Bash:
|
|
- 'ulimit -k' sets the maximum number of kqueues.
|
|
- 'ulimit -P' sets the maximum number of pseudo-terminals.
|
|
- 'ulimit -R' sets the maximum time in microseconds a real-time process
|
|
can run before blocking.
|
|
Note that to use these options the operating system must support the
|
|
corresponding resource limit.
|
|
|
|
- 'typeset' has a new '-g' flag that forces variables to be created or
|
|
modified at the global scope regardless of context, as on bash 4.2+.
|
|
|
|
New command line editor features:
|
|
|
|
- Various keys on extended PC keyboards are now handled as expected in the
|
|
emacs and vi built-in line editors: Ctrl or Alt + left or right arrow (go
|
|
back or forward one word), Ctrl+G (cancel reverse search), Ctrl+Delete
|
|
(delete next word). In addition, the Insert key now escapes the next
|
|
character in emacs and enters insert mode in vi, and the arrow keys are
|
|
recognized on more terminals.
|
|
|
|
New features in shell options:
|
|
|
|
- A new --functrace long-form shell option causes the -x/--xtrace option's
|
|
state and the DEBUG trap action to be inherited by function scopes instead
|
|
of being reset to default. Changes made to them within a function scope
|
|
still do not propagate back to the parent scope. Similarly, this option
|
|
also causes the DEBUG trap action to be inherited by subshells.
|
|
|
|
- The new --histreedit and --histverify options modify history expansion
|
|
(--histexpand). If --histreedit is on and a history expansion fails, the
|
|
command line is reloaded into the next prompt's edit buffer, allowing
|
|
corrections. If --histverify is on, the results of a history expansion are
|
|
not immediately executed but instead loaded into the next prompt's edit
|
|
buffer, allowing further changes.
|
|
|
|
### MAIN CHANGES between 1.0.0-beta.1 and 1.0.0-beta.2 ###
|
|
|
|
New features in built-in commands:
|
|
|
|
- 'cd' now supports an -e option that, when combined with -P, verifies
|
|
that $PWD is correct after changing directories; this helps detect
|
|
access permission problems. See:
|
|
https://www.austingroupbugs.net/view.php?id=253
|
|
|
|
- 'printf' now supports a -v option as in bash. This assigns formatted
|
|
output directly to variables, which is very fast and will not strip
|
|
final newline (\n) characters.
|
|
|
|
- The 'return' command, when used to return from a function, can now
|
|
return any status value in the 32-bit signed integer range, like on
|
|
zsh. However, due to a traditional Unix kernel limitation, $? is
|
|
still trimmed to its least significant 8 bits whenever leaving a
|
|
(sub)shell environment.
|
|
|
|
- 'test'/'[' now supports all the same operators as [[ (including =~,
|
|
\<, \>) except for the different 'and'/'or' operators. Note that
|
|
'test'/'[' remains deprecated due to its unfixable pitfalls;
|
|
[[ ... ]] is recommended instead.
|
|
|
|
Shell language changes:
|
|
|
|
- Several improvements were made to the --noexec shell code linter.
|
|
|
|
- Arithmetic expressions in native ksh mode no longer interpret a
|
|
number with a leading zero as octal in any context. Use 8#octalnumber
|
|
instead (e.g. 8#400 == 256). Arithmetic expressions now also behave
|
|
identically within and outside ((...)) and $((...)).
|
|
|
|
- POSIX compatibility mode fixes (only applicable with the --posix shell
|
|
option on):
|
|
- A leading zero is now consistently recognised as introducing an octal
|
|
number in all arithmetic contexts.
|
|
- $((inf)) and $((nan)) are now interpreted as regular variables.
|
|
- The '.' built-in no longer runs ksh functions and now only runs
|
|
files.
|
|
|
|
Bugs fixed:
|
|
|
|
- '.' and '..' are now once again completed by tab completion.
|
|
|
|
- If SIGINT is set to ignore, the interactive shell no longer exits on
|
|
Ctrl+C.
|
|
|
|
- ksh now builds and runs on Apple's new M1 hardware.
|
|
|
|
- The 'return' and 'exit' commands no longer risk triggering actual
|
|
signals by returning or exiting with a status > 256.
|
|
|
|
- Ksh no longer behaves badly when parsing a type definition command
|
|
('typeset -T' or 'enum') without executing it or when executing it in
|
|
a subshell. Types can now safely be defined in subshells and defined
|
|
conditionally as in 'if condition; then enum ...; fi'.
|
|
|
|
- Discipline functions, especially those applied to PS2 or .sh.tilde,
|
|
will no longer crash your shell upon being interrupted or throwing an
|
|
error.
|
|
|
|
- Fixed a bug that could corrupt output if standard output is closed
|
|
upon initialising the shell.
|
|
|
|
- Fixed a bug in the [[ ... ]] compound command: the '!' logical
|
|
negation operator now correctly negates another '!', e.g.,
|
|
[[ ! ! 1 -eq 1 ]] now returns 0/true. Note that this has always been
|
|
the case for 'test'/'['.
|
|
|
|
- Fixed SHLVL so that replacing ksh by itself (exec ksh) will not
|
|
increase it.
|
|
|
|
- Arithmetic expressions are no longer allowed to assign out-of-range
|
|
values to variables of types declared with enum.
|
|
|
|
- The 'time' keyword no longer makes the --errexit shell option
|
|
ineffective.
|
|
|
|
- Various bugs in libcmd built-in commands (those bound to the
|
|
/opt/ast/bin path by default) have been fixed.
|
|
|
|
- Various other crashing bugs have been fixed.
|
|
|
|
Fixes for the shcomp byte code compiler:
|
|
|
|
- shcomp is now able to compile scripts that define types using enum.
|
|
|
|
- shcomp now refuses to mess up your terminal by writing bytecode
|
|
to it.
|
|
|
|
### MAIN CHANGES between ksh 93u+ 2012-08-01 and 93u+m 1.0.0-beta.1 ###
|
|
|
|
Hundreds of bugs have been fixed, including many serious/critical bugs.
|
|
This includes upstreamed patches from OpenSUSE, Red Hat, and Solaris, fixes
|
|
backported from the abandoned 93v- beta and ksh2020 fork, as well as many
|
|
new fixes from the community. See the NEWS file for more information, and
|
|
the git commit log for complete documentation of every fix. Incompatible
|
|
changes have been minimised, but not at the expense of fixing bugs. For a
|
|
list of potentially incompatible changes, see src/cmd/ksh93/COMPATIBILITY.
|
|
|
|
Though there was a "no new features, bugfixes only" policy, some new
|
|
features were found necessary, either to fix serious design flaws or to
|
|
complete functionality that was evidently intended, but not finished.
|
|
Below is a summary of these new features.
|
|
|
|
New command line editor features:
|
|
|
|
- The forward-delete and End keys are now handled as expected in the
|
|
emacs and vi built-in line editors.
|
|
|
|
- In the vi and emacs line editors, repeat count parameters can now also
|
|
be used for the arrow keys and the forward-delete key. E.g., in emacs
|
|
mode, <ESC> 7 <left-arrow> will now move the cursor seven positions to
|
|
the left. In vi control mode, this would be entered as: 7 <left-arrow>.
|
|
|
|
- When the -b/--notify shell option is on and the vi or emacs/gmacs shell
|
|
line editor is in use, 'Done' and similar notifications from completed
|
|
background jobs are now inserted directly above the line you're typing,
|
|
without affecting your command line display.
|
|
|
|
New shell language features:
|
|
|
|
- The &>file redirection shorthand (for >file 2>&1) is now available for
|
|
all scripts and interactive sessions and not only for profile/login
|
|
scripts, bringing ksh 93u+m in line with mksh, bash, and zsh.
|
|
|
|
- File name generation (a.k.a. pathname expansion, a.k.a. globbing) now
|
|
never matches the special navigational names '.' (current directory)
|
|
and '..' (parent directory). This change makes a pattern like .*
|
|
useful; it now matches all hidden files (dotfiles) in the current
|
|
directory, without the harmful inclusion of '.' and '..'.
|
|
|
|
- Tilde expansion can now be extended or modified by defining a
|
|
.sh.tilde.get or .sh.tilde.set discipline function. This replaces a
|
|
2004 undocumented attempt to add this functionality via a .sh.tilde
|
|
command, which never worked and crashed the shell. See the manual for
|
|
details on the new method.
|
|
|
|
- A new ${.sh.pid} variable has been added with similar functionality to
|
|
Bash's $BASHPID variable. It is set to the current shell's PID, unlike
|
|
$$ (which is set to the main shell's PID). In virtual subshells
|
|
${.sh.pid} is not changed from its previous value, while in forked
|
|
subshells ${.sh.pid} is set to the subshell's process ID.
|
|
|
|
New features in built-in commands:
|
|
|
|
- Usage error messages now show the --help/--man self-documentation options.
|
|
|
|
- Path-bound built-ins (such as /opt/ast/bin/cat) can now be executed by
|
|
invoking the canonical path, so the following will now work as expected:
|
|
$ /opt/ast/bin/cat --version
|
|
version cat (AT&T Research) 2012-05-31
|
|
|
|
- 'command -x' now looks for external commands only, skipping built-ins.
|
|
In addition, its xargs-like functionality no longer freezes the shell on
|
|
Linux and macOS, making it effectively a new feature on these systems.
|
|
|
|
- 'redirect' now checks if all arguments are valid redirections before
|
|
performing them. If an error occurs, it issues an error message instead
|
|
of terminating the shell.
|
|
|
|
- 'suspend' now refuses to suspend a login shell, as there is probably no
|
|
parent shell to return to and the login session would freeze.
|
|
|
|
- 'times' now gives high precision output in a POSIX compliant format.
|
|
|
|
- 'typeset' now gives an informative error message if an incompatible
|
|
combination of options is given.
|
|
|
|
- 'whence -v/-a' now reports the location of autoloadable functions.
|
|
|
|
New features in shell options:
|
|
|
|
- A new --globcasedetect shell option is added on OSs where we can
|
|
check for a case-insensitive file system (currently Windows/Cygwin,
|
|
macOS, Linux and QNX 7.0+). When this option is turned on, file name
|
|
generation (globbing), as well as file name tab completion on
|
|
interactive shells, automatically become case-insensitive on file
|
|
systems where the difference between upper and lower case is ignored
|
|
for file names. This is transparently determined for each directory, so
|
|
a path pattern that spans multiple file systems can be part
|
|
case-sensitive and part case-insensitive.
|
|
|
|
- A new --nobackslashctrl shell option disables the special escaping
|
|
behaviour of the backslash character in the emacs and vi built-in
|
|
editors. Particularly in the emacs editor, this makes it much easier to
|
|
go backward, insert a forgotten backslash into a command, and then
|
|
continue editing without having your next cursor key replace your
|
|
backslash with garbage. Note that Ctrl+V (or whatever other character
|
|
was set using 'stty lnext') always escapes all control characters in
|
|
either editing mode.
|
|
|
|
- A new --posix shell option has been added to ksh 93u+m that makes the
|
|
ksh language more compatible with other shells by following the POSIX
|
|
standard more closely. See the manual page for details. It is enabled by
|
|
default if ksh is invoked as sh, otherwise it is disabled by default.
|
|
|
|
- Enhancement to -G/--globstar: symbolic links to directories are now
|
|
followed if they match a normal (non-**) glob pattern. For example, if
|
|
'/lnk' is a symlink to a directory, '/lnk/**' and '/l?k/**' now work as
|
|
you would expect.
|