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

Read from stdin by default #275

Open mrnoname1000 opened 5 months ago

mrnoname1000 commented 5 months ago

Having to specify -f - when using trurl in a pipeline is a little clunky. IMO if no URLs are provided on the command line, trurl should behave as if -f - was passed. This would streamline the usage of trurl in a pipeline and make it behave more like a Unix text-processing utility. It also has the benefit of not changing any existing behavior except error handling.

jacobmealey commented 4 months ago

Okay, I worked through implementing this (twice actually lol) and @emanuele6 pointed out a flaws with this. manually specifying -f - avoids a lot of weird edge cases in shell scripts where stdin has already been redirected that would require tacking on a < /dev/null. see #288 discussion for more details. @bagder can we close this issue?

mrnoname1000 commented 4 months ago

I would argue that behavior is correct, since almost every other text processing utility behaves that way, e.g. cat "$@" or sed 's/foo/bar/' "$@" (without checking for a tty I might add).

However, it sounds like this would be a major, breaking change to trurl. I'd be fine closing this issue but I'd like to highlight #274 which would somewhat mitigate my gripes.