If they're not that savvy, tell them to stop using spaces in their filenames ;-)

There really is no straight-forward, simple, and portable answer to your question, short of some minor retraining of your users. For example, if I specify "--cfg=my  cfg" with two spaces, there's basically no way to recover that - the shell will eat the spaces. (Some shells may save the original command in an environment variable, but, again, it's not portable, and may not apply to your shell/OS/users.) You could, I suppose, use *'s instead of -'s or _'s and the glob function, but at some point you're getting far too smart and will likely end up getting in trouble.

If you continue to try, you may have to pre-process @ARGV, merging any argument that doesn't start with a dash in with the previous argument. But, even then, it gets annoying, really fast.

Also, your interface will be completely non-standard. Users learning your way of doing things will not be able to apply that knowledge to any other application. However, if you teach them the "normal" way (quoting, or just putting in the dashes if that's what they want to use), that knowledge and experience will then transfer to any other program they use.

Sounds like what you really need is a GUI interface for users who can't handle the command line :-) (And lest that sound condescending, it's not intended to - presumably those users are providing other value to their employer to justify their salary which would be more valuable than another command-line expert :-) )


In reply to Re^3: Parsing Command Line Options by Tanktalus
in thread Parsing Command Line Options by mmartin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.