Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Or you could use this in a library like sh with

    sh(t"stat {some_file}")
With t-strings you could run proper escaping over the contents of `some_file` before passing it to a shell.

I'd have to take a look at the order things happen in shell, but you might even be able to increase security/foot-gun-potential a little bit here by turning this into something like `stat "$( base64 -d [base64 encoded content of some_file] )"`.



You should check out PEP 787


Oh! I missed this one because I've been looking specifically at the Packaging forum rather than the PEPs forum. This looks like a brilliant use case. (I'm aiming for wide compatibility - back to 3.6 - with my current projects, but I look forward to trying this out if and when it's accepted and implemented.)

Now if only the overall `subprocess` interface weren't so complex....


We really should just point most of these comments at that PEP. Thanks for getting it out so fast.


PEP 787 – Safer subprocess usage using t-strings https://peps.python.org/pep-0787/


Hmm, PEP-787 has some interesting discussions around it. I'll have to sort my thoughts on these aspects a bit.


Not Python but this is exactly the idea behind zx

https://github.com/google/zx




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: