If you’re averse to this:
q(“select x where y = ‘“ + v + “‘“)
And instead do this: q(“select x where y = %s”, v)
Then you should be averse to this: x(“foo --option ‘“ + v + “‘“)
And instead do this: x(‘foo --option “$1”’, v)
This is particularly useful when it’s expedient to have one thing piping into another. Like it or not the sh DSL for pipes is excellent compared to doing things natively with execve() and pipe(), just as doing group by and count is far more concise in SQL than doing so natively.Most SQL libraries give you something like q. Writing your own x is as simple as calling sh correctly. In Python, for example:
def x(script, *args):
run([“sh”, “-c”, script, “--“, *args])