I sometimes use the wrong syntax on the script in question.
In that case perhaps the simplest solution is to require the -i option in your script, thereby always requring one to specify a filename or "-"?
| [reply] [d/l] [select] |
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.
| [reply] [d/l] |
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.
| [reply] [d/l] [select] |