-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
History pattern search menu (SHOPT_EDPREDICT) needs work #233
Comments
Well, you just taught me all sorts of goodies that I did not know existed. Let me summarize what you are requesting or stated from my current understanding of this issue:
Additionally, I have found that you can backslash escape the $ \#s
-ksh: #s: not found |
While experimenting with ksh93#233, a memory segmentation fault occurred. A search of other emacs issues found a potential matching issue as described in att#791. Also, a duplicate PR of att#1489 was submitted. This commit backports that fix. src/cmd/ksh93/edit/history.c: hist_word(): - Switch from using strcpy to memmove as the two strings could overlap.
@hyenias Am I understanding that you are seeing this hash-activated search as well? If it's supposed to be doing it, why don't all copies of It may display a menu, but the menu doesn't work. Further, I would not ever expect that bringing a line back from history, that began with a hash, would immediately trigger the mechanism again. Edit... I understand now how the menu works, you use the arrow keys and it changes the list without placing the currently selected result on the command line! Least surprise, much? |
Your # 4 is documented on p107 of the Bolsky. |
While experimenting with #233, a memory segmentation fault occurred. A search of other emacs issues found a potential matching issue as described in att#791. Also, a duplicate PR of att#1489 was submitted. This commit backports that fix. src/cmd/ksh93/edit/history.c: hist_word(): - Switch from using strcpy to memmove as the two strings could overlap.
Lines 780 to 786 in 3abbb0d
|
Yes, as you have enlightened me to its existence. I have been playing around with it. The menu works differently than the file completion menu. Not sure why all copies of ksh do it as that is too large of a scope to understand--need to know the version of each ksh plus etc. Control?, meaning option. It appears this # menu-based history completion is an added feature that works both in emacs and vi editing modes.
This # menu-based history completion selection works differently than the file menu one at present. I am able to use my arrows keys to cycle to a choice on the first line aka As I typed this response, @McDutchie has provided the answer on option and its use. I do not posses the Bolsky book. I am so jealous. My book has nothing under its In-Line Editor section for comments. |
I think we broke it. I can't get the search to function correctly. My history is full of commands that contain I can't get any version to make |
Ok, that's just broken. What crazy person thought subverting ksh syntax like that was a good idea? And you can't turn it off at runtime? Better... why does the same source tree have that compiled in on macOS and not on Linux? It's not like I enabled it on one and not the other... I didn't know it was there. Whereinh*ll is that defined? RELEASE implies that, assuming it's on, it should be active whether emacs or vi or none are active:
Further, this comment in RELEASE seems relevant:
|
Inexpensive second-hand copies are readily available, e.g. here. |
On my end, it compiles for Linux the same as it does for macOS. It works in both emacs and vi modes on both systems. You do of course have to make sure to enable either emacs or vi. |
On the Linux machine, make.out shows that it's being defined:
And emacs mode is on:
But I can type all the comments I want at a prompt and never trigger it:
That above does NOT work on the Mac... the moment I hit the
Same version of |
On the Mint machine, you probably don't have a comment containing |
Whyinh*ll is this on by default? I'm amazed that I've never tripped over this before. Not that you can answer that question, I'm ranting. How do I turn this off... Edit... obviously I can pass -USHOPT_EDPREDICT (and did) but where is it deciding to include this? |
Oh, gods... From https://www.mail-archive.com/[email protected]/msg01272.html
Never mind that if you're at the bottom of a window, the session scrolls... SMH... |
@McDutchie You applied this in db5621d ... what does it actually do? Ridiculous that bug reports in software that's not theirs would be private... |
But I do have such strings in the history... after the first But it finds it on the Mac. |
Side note... @hyenias I can recommend ThriftBooks on Amazon, that's the vendor I got both my Bolsky books from. |
As of 6cc2f6a, you can edit |
The following block of code is used by ksh to fill in editor prediction matches after a tab: ksh/src/cmd/ksh93/edit/emacs.c Lines 988 to 1002 in 3abbb0d
When ksh rejects one of the options from the list ( Lines 1743 to 1747 in 3abbb0d
GDB backtrace from the crash:
|
Here's a related bug for you in If you trigger the search, type some text that generates matches, then
Type
The menu is still active and you can still make selections from it, even though there really should be no search active. @JohnoKing I managed to trigger the fault from #233 (comment) while writing this. |
Funny. Now it (sort of) works again on my system, for no apparent reason. In any case, I tend to agree with @posguy99 about this feature. In summary:
So, I propose we remove this experimental SHOPT_EDPREDICT feature. @JohnoKing, @hyenias, what say you? |
I agree, especially with this point. I always find myself using reverse search instead (usually with the up arrow, sometimes with Ctrl+R). |
My view is to simply set the default compile option to All-in-all, if we become aware of the usefulness this # menu-based history search selection, then it could be altered or improved to a point of overall acceptance. I believe in a phase out approach instead of immediate deletion aka deprecate code with user notification along with timeline. |
Myself, I run with it turned off right now. Once you see it, it's like a gnat, you can't unsee it. But delete it? Not so sure. re @hyenias question... Do those who ship ksh93u+ have it enabled or disabled? I know Apple has it enabled, I know Linux Mint has it enabled which means Ubuntu has it enabled which means Debian has it enabled. Of course, do they know it's enabled? |
To add onto the discussion, I'll note that predictive editing is disabled on Solaris (possibly because of this bug): |
Right, looks like there is a consensus for turning it off by default. I don't want to keep shipping broken stuff forever (even turned off), but I'm okay with that for the first few releases (perhaps versions 1.*). It gives the community a chance to take an interest in it and possibly fix it. I doubt that will actually happen but I've been wrong before. |
If it is fixed, another thing that needs doing is a shell option that allows users to turn this on or off at runtime. |
Having another character as the trigger would go a long way, too. |
That character could easily be made configurable with a variable. |
It's experimental, undocumented, at least somewhat broken, and gets in the way if you type a comment. Should not be enabled by default, at least not until someone steps up to fix it properly. This commit also updates the descriptions of the option to clarify that this provides a pattern-based history search menu. "Predictive editing" is a misnomer as this does not predict anything. Note that Solaris already disables it by default: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/165-CR7186440_ksh93_disable_predictive_editing.patch Discussion: #233
@posguy99 exactly! I was thinking along the lines of using a non-printable key such as a function key (F1-F10) and allow the menu to be launched at any point not just the first character of the line. |
@hyenias That wouldn't work. Function keys are multi-byte ANSI sequences. Yes, if the running KSH had intimate knowledge of where it was running, it could capture actual low-level key codes, but it'd never work through, say, an SSH session. It really has to be a printable character. The hash sign was just a singularly bad choice. |
ksh already interprets multi-byte ANSI sequences such as your up-arrow key, so there's no real reason it couldn't be done, although it might be nontrivial. |
Yeah, I know @JohnoKing fixed it, but to me up arrow is |
My thoughts are that this menu that is activated by a leading hash should instead be activated by |
Interest seems to have died out here. If no one takes this up, I'll remove SHOPT_EDPREDICT after the 1.0 release to avoid bit rot. |
The SHOPT_EDPREDICT compile-time option has been removed from the dev branch (see #233) but kept on the 1.0 branch. Building with this option enabled in SHOPT.sh was subsequently broken by the three referenced commits as changes were cherry-picked from the dev branch, which of course did not include the necessary code changes to the SHOPT_EDPREDICT code. This commit backports those changes. Thanks to @k2662 for the report. Resolves: #786
Would someone point me to some documentation that says when
set -o emacs
is active, a hash as the first character of a line is not a comment but is instead a search command?I'm sorry, it sounds elementary and stupid, but
ksh93u
andksh93u+m
behave exactly the same on the Mac and both behave the same and do NOT do the same thing on a Linux VM with exactly the same rc files.With no rc file at all they both still do it on the Mac. Two different Mac. Catalina 10.15.7.
I typed
#s
at the prompt.If the input is
<space>#<some_text>
, it's taken as a comment. If you type some text and then use ESC-# , the shell prepends a hash and moves to the next line. It adds that line to the history and if you bring it back with an up-arrow it tries to intrepret the hash as a search command again.It's not Terminal.app, iTerm2 does it too.
The text was updated successfully, but these errors were encountered: