4 ms·
Why is this downvoted? What's the problem with this solution? It looks like the same kind of thing as Python's shlex.quote, which should work and about which th
by ptx 5y ago
Why is this downvoted? What's the problem with this solution? It looks like the same kind of thing as Python's shlex.quote, which should work and about which the manual[1] says:
"The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list."
[1] https://docs.python.org/3/library/shlex.html#shlex.quote https://docs.python.org/3/library/shlex.html#shlex.quote
- mullikine 5y agoI made too many edits. HN autovoted down. It's legit
- Aachen 5y agoI don't think editing your post results in the server downvoting it. Not sure if I understood your comment correctly.
- mullikine 5y ago`myeval` is more subtle. It is like eval but reliably escapes and evaluates the arguments as a single command. cmd 'hello '\'''\'''\'''\''"simon' 'thanks' 'for' 'lunch' # Output: 'hello '\'''\'''\'''\''"simon' 'thanks' 'for' 'lunch' # The fact that myeval seems useless here is testament to its greatness myeval cmd 'hello '\'''\'''\'''\''"simon' 'thanks' 'for' 'lunch' # Output: 'hello '\'''\'''\'''\''"simon' 'thanks' 'for' 'lunch' # eval isn't great though eval cmd 'hello '\'''\'''\'''\''"simon' 'thanks' 'for' 'lunch' # Error: zsh: unmatched "