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.
I don't think using shlex.quote is the right choice here, because it quotes strings in ways that are parseable 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 the master branch code as echo '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.
Using shlex.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.

Fix the problem from #210
The problem occurs when
mprof run <command>has multi-line arguments:For example: