File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -180,8 +180,13 @@ class PubCommandRunner extends CommandRunner {
180
180
if (topLevelResults['trace' ]) {
181
181
log.dumpTranscript ();
182
182
} else if (! isUserFacingException (error)) {
183
- // TODO(23505): Implement proper shell escaping, not a partial hack.
184
- protectArgument (String x) => x.contains (' ' ) ? '"$x "' : x;
183
+ // Escape the argument for users to copy-paste in bash.
184
+ // Wrap with single quotation, and use '\'' to insert single quote, as
185
+ // long as we have no spaces this doesn't create a new argument.
186
+ protectArgument (String x) =>
187
+ RegExp (r'^[a-zA-Z0-9-_]+$' ).stringMatch (x) == null
188
+ ? "'${x .replaceAll ("'" , r"'\''" )}'"
189
+ : x;
185
190
log.error ("""
186
191
This is an unexpected error. Please run
187
192
You can’t perform that action at this time.
0 commit comments