curl / trurl

trurl is a command line tool for URL parsing and manipulation.
https://curl.se/trurl/
Other
3.1k stars 99 forks source link

Trurl accept from stdin #288

Closed jacobmealey closed 4 months ago

jacobmealey commented 4 months ago

this is a second pass at #277, I'm not sure what I was doing last time but the tests seem to be working now. I left the original -f - behavior unchanged, but with this I think could we could take it out as its redundant - but also its a pretty common pattern so I have no strong feelings either way about keeping -f - in. Fixes #275

emanuele6 commented 4 months ago

I don't like this at all

emanuele6 commented 4 months ago

If I use trurl -g {host} -- "${urls[@]}", and stdin happens to not be a terminal, and urls is empty, my script now either gets stuck reading stdin or corrupts my stdin reading it. And the only thing I can do to avoid this is trurl -g {host} -- "${urls[@]}" </dev/null...

jacobmealey commented 4 months ago

If I use trurl -g {host} -- "${urls[@]}", and stdin happens to not be a terminal, and urls is empty, my script now either gets stuck reading stdin or corrupts my stdin reading it.

I didn't think of that. shoot. having to redirect /dev/null is not good. I'm wondering if there is a way we can do this at all without getting into the situation described above. The issue really at hand is the implicit reading from standard which would be a really nasty bug to try and catch from a shell script point of view. The only way i see out of it would be using a command line flag... which gets us right back to -f.

If we close this PR we should also close #275 as well.

emanuele6 commented 4 months ago

I don't think #275 is a good suggestion; I much prefer specifying -f -.

jacobmealey commented 4 months ago

Okay, will close this PR.