in reply to Why is it good practice for a cli script to take switch args before file list?

Perhaps because if switches could occur after the start of the filename list, how could you tell whether "-f" is a filename or a switch?

Bear in mind that "-f" is a perfectly fine filename, since filenames (at least in unix) can contain any byte that isn't "\0" or "/".

By having the restriction "all switches before any filename list", you can ensure that once you stop looking at switches (including having processed the "--" standard switch), everything that remains, no matter how whacky looking, is intended to be a filename.

I think that's rather sane.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re: Why is it good practice for a cli script to take switch args before file list?