We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bb2b8b2 commit 154a141Copy full SHA for 154a141
lib/src/command_runner.dart
@@ -180,8 +180,13 @@ class PubCommandRunner extends CommandRunner {
180
if (topLevelResults['trace']) {
181
log.dumpTranscript();
182
} else if (!isUserFacingException(error)) {
183
- // TODO(23505): Implement proper shell escaping, not a partial hack.
184
- protectArgument(String x) => x.contains(' ') ? '"$x"' : x;
+ // Escape the argument for users to copy-paste in bash.
+ // 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;
190
log.error("""
191
This is an unexpected error. Please run
192
0 commit comments