4 ms·
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` befo
by tetha 1y ago
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] )"`.
- nhumrich 1y agoYou should check out PEP 787
- tetha 1y agoHmm, PEP-787 has some interesting discussions around it. I'll have to sort my thoughts on these aspects a bit.
- pauleveritt 1y agoWe really should just point most of these comments at that PEP. Thanks for getting it out so fast.
- zahlman 1y agoOh! 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....
- Flimm 1y agoPEP 787 – Safer subprocess usage using t-strings https://peps.python.org/pep-0787/ https://peps.python.org/pep-0787/
- dhruvrajvanshi 1y agoNot Python but this is exactly the idea behind zx https://github.com/google/zx https://github.com/google/zx