-
Notifications
You must be signed in to change notification settings - Fork 181
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
driver/shelldriver: handle bracketed-paste mode #975
driver/shelldriver: handle bracketed-paste mode #975
Conversation
bash >= 5.1 and readline >= 8.1 enable bracketed-paste mode by default, allowing the terminal emulator to tell a program whether input was typed or pasted. To achieve this, "\e[?2004h" is inserted when user input is expected enabling paste detection. "\e[?2004l" is inserted to disable it. To handle the escape sequences, match the enable sequence between marker and prompt. The disable sequence is already stripped by the regex removing all VT100 codes. Signed-off-by: Bastian Krause <bst@pengutronix.de>
Codecov Report
@@ Coverage Diff @@
## master #975 +/- ##
======================================
Coverage 61.7% 61.7%
======================================
Files 150 150
Lines 11219 11219
======================================
Hits 6932 6932
Misses 4287 4287
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to disable this feature?
_, _, match, _ = self.console.expect( | ||
rf'{marker}(.*){marker}\s+(\d+)\s+{self.prompt}', | ||
rf'{marker}(.*){marker}\s+(\d+)\s+(\x1b\[\?2004h)?{self.prompt}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only matches the escape sequence at a specific location, which seems fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If (on a given system) this always appears at the start of the prompt, the user could add this to their prompt regex instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. On the one hand it feels a bit like a work-around, but on the other you could probably argue that this belongs to the prompt somewhat. So I agree that we consider this a valid solution.
We could run |
(Was directed here from the discussion in #1397, so just my 2 cents)
+2 (myself and @khilman #1397 (comment))
This feature is supposed to be functional on the DUT; therefore, disabling the feature and conducting the test without it contradicts the purpose of the testing, doesn't it?
IMO it belongs to the underlying shell/terminal, not the prompt itself. |
Description
bash >= 5.1 and readline >= 8.1 enable bracketed-paste mode by default, allowing the terminal emulator to tell a program whether input was typed or pasted. To achieve this,
\e[?2004h
is inserted when user input is expected enabling paste detection.\e[?2004l
is inserted to disable it.To handle the escape sequences, match the enable sequence between marker and prompt. The disable sequence is already stripped by the regex removing all VT100 codes.
See pexpect/pexpect#669
Tested with readline 8.1 and bash 5.1.16
Checklist
Fixes #969