Skip to content
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

Improve escaping of result.escapedCommand #874

Closed
ehmicky opened this issue Mar 1, 2024 · 0 comments · Fixed by #875
Closed

Improve escaping of result.escapedCommand #874

ehmicky opened this issue Mar 1, 2024 · 0 comments · Fixed by #875

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Mar 1, 2024

The original purpose of result.escapedCommand was to be able to copy and paste the command for debugging purpose.

However, we now use it for the verbose option. So it has a second purpose: being safe to print in a terminal.

Those two purposes are actually quite different:

  • The first requires quoting characters with special meaning in a given shell. For example $ in Unix shells. Since we don't know for sure which shell is being used, and since shells have very different escaping rules, there is no perfect way to achieve this. However, we can do a best effort.
  • The second requires escaping characters which have special meaning when printed in a terminal. That is: control characters. For example, ANSI color sequences (or sequences that move the cursor, clear the screen, etc.) should be represented using notations like \u, \x or \e.

Based on the above, our current logic is not perfect and could be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant