logoalt Hacker News

tayo42last Friday at 3:50 PM2 repliesview on HN

Pretty much anything longer then a throwaway one liner I write in python.

Would be cool if python had a pipe operator though.

The back ticks in ruby is pretty ergonomic too. Wish python had a simpler way to run commands. Kind of tedious to look up subprocess run arguments and also break things up into arrays.


Replies

kstrauseryesterday at 7:39 PM

You can always set shell=True and pass in an entire command line as a string, but… don’t do that. It seems really nice until the first time you get the shell escaping wrong, and then it’s something you tend never to do again.

For example,

  subprocess.run(“rm -rf ~/ some file”, shell=True)
and

  subprocess.run([“rm”, “-rf”,  “~/ some file”])
have significant different behavior.
show 1 reply
mackeyelast Friday at 11:27 PM

nushell (https://www.nushell.sh/) is essentially perfect for this use case! i use it rather than posix(y) shells for most projects where id normally reach for python.