fix(reporting) use single quoting when converting remediation commands - #921
Merged
Merged
Conversation
The remediation commands are provided as a list of arguments that is used in leapp-report.json. The same command is also converted to a string that is used in leapp-report.txt and can be copy-pasted by the user into shell. Originally, the command conversion tried to make the resulting commands prettier by enabling double quoting whenever there was a single quote in an argument, while still trying to make the double quoted argument a literal. This proved to be problematic approach due to multiple cases that resulted with incorrect commands. Namely, when the command called `bash -c` with a subcommand that would be evaluated by another non-interactive shell, or when there was an exclamation mark that would have different meaning in non-interactive and interactive shell and its escaping was not possible unless single-quotes are used. This patch makes the command conversion produce pretty commands in the most cases, moreover, it makes sure the command is always correct (if the list version is correct to begin with). This approach leaves possibility to encounter unintuitive escaping in the resulting converted command, although this can be prevented by carefully crafting the command when creating the report. Note that if there is a subcommand called in the converted command, the report creator is responsible for its form and for the best resulting command it should favor the double quoting of its arguments when possible.
PeterMocary
force-pushed
the
simplify-command-conversion
branch
from
April 13, 2026 10:40
1658232 to
5e9f55a
Compare
pirat89
approved these changes
Apr 16, 2026
pirat89
left a comment
Member
There was a problem hiding this comment.
discussed and tested on mtg. we agree with the change
Merged
pirat89
pushed a commit
that referenced
this pull request
Jul 29, 2026
## Packaging - Bump leapp-framework to 6.6 (#913, #919, #921, #929) ### Fixes - Change how commands are converted for text based report from the list representation (#919, #921) - Fix the crashing check of conflicts between actor config schemes (#925) ### Enhancements - Introduce the format_list function for unified presentation of lists in reports and logs (#913) ## stdlib ### Enhancements - Introduce the format_list function for unified presentation of lists in reports and logs (#913)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The remediation commands are provided as a list of arguments that is used in leapp-report.json. The same command is also converted to a string that is used in leapp-report.txt and can be copy-pasted by the user into shell.
Originally, the command conversion tried to make the resulting commands prettier by enabling double quoting whenever there was a single quote in an argument, while still trying to make the double quoted argument a literal. This proved to be problematic approach due to multiple cases that resulted with incorrect commands. Namely, when the command called
bash -cwith a subcommand that would be evaluated by another non-interactive shell, or when there was an exclamation mark that would have different meaning in non-interactive and interactive shell and its escaping was not possible unless single-quotes are used.This patch makes the command conversion produce pretty commands in the most cases (none of the current commands are affected as far as i could tell). Moreover, using shlex exclusively makes sure the command is always correct (if the list version is correct to begin with). This approach leaves possibility to encounter unintuitive escaping in the resulting converted command, although this can be prevented by carefully crafting the command when creating the report.
Note that if there is a subcommand called in the converted command, the report creator is responsible for its form and for the best resulting command it should favor the double quoting of its arguments when possible.
Bumps specifle version to 6.5
Jira: RHEL-156521
Related leapp-repository PR: PR#1520