-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v1.1] emacs ^X^E, vi v: avoid executing if command line not saved
@pghvlaans reports: > According to 'The New KornShell', the full editor history editing > commands are only meant to execute command lines that have had > saved changes: > > "The command is the ksh line that you were editing with the vi > built-in editor if you omit n, or command n in the history file. > When you exit the vi program, ksh displays and executes the > command if you have changed it. Version: With some early releases > of the 11/16/88 version of ksh, the file was executed even if you > had not changed it." (Bolsky & Korn, pg. 116) > > There is no other evidence that this functionality was ever part > of release ksh93, however. Neither bash nor any existing open > source ksh88 derivative behaves in this manner. Nevertheless, > some distributions of ksh88 (such as the one shipped with > UnixWare 7) did attempt to avoid running unchanged command lines > using timestamps. POSIX does not allow this behaviour for the fc command, but says nothing about the emacs ^X^E and vi v editor commands. I have concluded from the resulting discussion is that it is best to make the timestamp check on the temporary file subject to a new option to the fc/hist command, let's say -E. The emacs and vi commands can then invoke fc/hist with that new option. src/cmd/ksh93/bltins/hist.c, src/cmd/ksh93/data/builtins.c: - Add new -E option to fc/hist, remembered by the checktime flag. - When invoking the editor and checktime is set, use the libast tv(3) library to get the temporary file's timestamp before and after editing (with nanosecond granularity where available), and flag up an error if the timestamp has not changed. This has the effect of not executing the command line if a user quits the editor without saving. src/cmd/ksh93/data/msg.c: - Change e_runvi, the command used by ed_fulledit() (called by ^X^E in emacs and v in vi) to invoke a fullscreen editor, to invoke 'fc' with the new -E option. - 'fc' is the same as 'hist' but is shorter and standard. :) - Add a 'command' prefix to bypass a possible fc shell function. src/cmd/ksh93/sh.1: - Document the changes. - Remove mention of the specific shell command executed by the emacs and vi editor commands; that's an internal implementation detail. Resolves: ksh93#748
- Loading branch information
Showing
8 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters