Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Warn if STDIN pipe is missing or unwanted

by Anonymous Monk
on Jan 11, 2026 at 23:26 UTC ( [id://11167132]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Warn if STDIN pipe is missing or unwanted
in thread Warn if STDIN pipe is missing or unwanted

That doesn't address the issue of accidentally running ./script.pl -i - without an input source for STDIN. That seems like an error to me. Making '-i' required also would preclude allowing input exclusively from @ARGV. I modeled the UI somewhat on wget/aria2c/(and very recently curl), where you can pass a few inputs in @ARGV, but can pass an input file for larger batches. Of course the simplest answer is to only allow input from @ARGV and use xargs to feed from other input sources, but that results in less ease of use.

Replies are listed 'Best First'.
Re^5: Warn if STDIN pipe is missing or unwanted
by haukex (Archbishop) on Jan 12, 2026 at 09:26 UTC
    That doesn't address the issue of accidentally running ./script.pl -i - without an input source for STDIN.

    Sorry, but that doesn't make sense to me at all: if I told the program that I want it to take input from STDIN, then it doing exactly what I asked it to doesn't mean the program is "hanging" - maybe I really did want to type input in the console manually. In other words, telling the program explicitly "-i -" and then not giving it anything on STDIN is operator error, and IMHO not something the program should worry about.

    Making '-i' required also would preclude allowing input exclusively from @ARGV.

    Then get rid of -i entirely and do it like most other *NIXish programs, just take a list of input files from @ARGV, optionally requiring at least one filename if you don't want the default behavior of "empty @ARGV means STDIN" - forgetting the latter is a common and understandable thing in my experience.

    I modeled the UI somewhat on wget/aria2c/(and very recently curl), ...

    The fact that some programs get creative with their command line arguments doesn't mean you have to. Sorry, but I think you're overengineering here, and I really don't mean that as an insult - I've done that to myself plenty of times. Take a step back, think about what problem you're really trying to solve for, and whether the fix really needs to be such a complex thing as the root node is attempting. The *NIX way of command-line argument handling is a (quasi-)standard for a reason, part of that reason being that if all programs use similar command-line argument handling, it's easier for the operator to remember and avoid mistakes.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11167132]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2026-04-12 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.