- Notifications
You must be signed in to change notification settings - Fork384
Handle multiline command-line args#363
Handle multiline command-line args#363stepan-anokhin wants to merge 1 commit intopythonprofilers:masterfrom
Conversation
| """Given a set or arguments, compute command-line.""" | ||
| blanks = set(' \t') | ||
| args = [s if blanks.isdisjoint(s) else "'" + s + "'" for s in args] | ||
| args = [shlex.quote(s).replace('\n', '\\n') for s in args] |
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.
I don't think usingshlex.quote is the right choice here, because it quotes strings in ways that areparseable by the shell, and the strings encoded in the file will never be parsed by the shell. But the shell-escaped versions look ugly in the plots.
For example, this command:
mprof echo "Hello's fine"...will be escaped by themaster branch code asecho 'Hello's fine' which looks sort of nonsensical but it's fine, it doesn't matter if the quoting is legal, just that it's intelligible in the plot.
Usingshlex.quote, though, what you get for a plot label is not really an improvement:
Doing the.replace('\n', '\\n') is a good idea (though I think newlines could also just be replaced with a space, and it would be fine), but the quoting should be left to simple, not-technically-correct-but-we-get-the-idea logic like in the previous code.

Uh oh!
There was an error while loading.Please reload this page.
Fix the problem from#210
The problem occurs when
mprof run <command>has multi-line arguments:For example: