Well, if a primary objective is to protect simple-minded users from the complexities of the shell, you really should avoid using angle brackets on the command line altogether.

To put that another way, if users don't want to be bothered with the standard usage of angle brackets, things will go much better for all concerned if you simply forbid any use of angle brackets.

Why? Because when you forget to use quotes in OP approach to appending, you can get in bad trouble. REALLY Bad Trouble. As in, deleting the very data you were supposed to preserve by appending.

So do it like this:

Usage: script_name [-a] output_file_name by default, output_file is created as a new file use "-a" to have output appended to existing output_file
That is, use "-a" instead of an angle bracket. Or better yet (assuming that it's more important to avoid deleting existing data), make appending the default mode of operation, and have an option "-n" (for "new") or "-b" (for "begin" or "blank-slate") or whatever, to create/truncate the output file.

Rest assured, the OP design is the farthest thing from "user friendly". You have to do better than that.


In reply to Re^3: Append to file or create file depending on input filename. by graff
in thread Append to file or create file depending on input filename. by markuhs

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.