3 ms·
You can implement this and many other single purpose CLI tools with inline Python or Perl or other language. Easier to remember because it's your favorite langu
by visarga 5y ago
You can implement this and many other single purpose CLI tools with inline Python or Perl or other language. Easier to remember because it's your favorite language.
python -c "import json; print(json.dumps(dict(a=10, b=False)))"
- Too 5y agoWhile a handy trick, it doesn't entirely solve the original problem when the values have dynamic content. In your example, replace 10 with $FOO and then you are back to square one, having to escape python-strings within a shell-string. Better avoid the problem entirely by not using shell to begin with. To instead continue on the dirty track, replace 10 with int(sys.argv[1]) and call it as python -c "..." $FOO.