[net.micro.amiga] A simple CLI trick

hadeishi@husc4.harvard.edu (mitsuharu hadeishi) (10/30/86)

	I, like most of you, have always cursed the CLI for not having
certain nice UNIX-style syntax for certain commands; in particular,
not being able to refer to a bunch of files in a single command
(for example with copy, dir, search, etc.)

	How many times have you wanted to do something like
"copy file1 file2 file3 destination"?  And then realized, UGH, the
CLI doesn't support this syntax for "copy".  Or did a long
"delete file1 file2 file3 file4 file5 file6" and then realized
that you made a typo and because ONE of the files wasn't there the
whole command was aborted!  Or wanted to search only three source
files in a long directory, not just all the files matching #?.c ???

	"Can't be done," you say.  "Just have to issue the commands over
and over" you say.  "This ain't UNIX," you say.  "What's wrong with
'copy first ram:, copy next ram:, copy another ram:, copy mybrother ram:",
anyway?  Just a few extra keystrokes," you say.

	But wait!  Just yesterday I was paging through my (tr|d|m)usty old
DOS User's Manual (a document I haven't looked at for months) and
happened to notice the section on pattern matching.  "Yawn," I thought.
"But hold it . . . there seems to be a pretty powerful set of
pattern matching metacharacters there, if used prop . . . wait a minnit!"

	I think even C-A doesn't know about this one; if you take
a close look at their sample CLI scripts, they typically have long
sequences of copy commands in a row.  But this ignores the rather
powerful pattern matching facility in AmigaDOS, which allows the
following revolutionary though "it's-obvious-to-me-now" syntax:

	COPY (firstfile|nextfile|anotherfile) destinationdirectory

	There is no stated limit on how many files, but I've only
tested it on a few files at once.  Note that this syntax works for
COPY, DIR, SEARCH, DELETE, and LIST PAT, and should work for others
as well.  DELETE does allow multiple files in the command line, but
it coughs and dies without doing anything if even ONE of the files
in the list does not exist.  However with pattern matching it 
it will delete all the files in the list, ignoring the files in
the list that don't exist (how nice).  In addition, it prints each
file as it is deleted, unlike the usual multiple-file DELETE (so you
know if one of the files in the list wasn't there).

	Now who said the CLI didn't have any surprises left?

				-Mitsu

cc1@locus.ucla.edu (Michael Gersten) (10/31/86)

Unfortunately, that method ONLY works for those commands. Further,
LIST PAT only works for displaying *files*; if you want to do something
lie

ls /usr/{lib,spool}/news
 
or 
 
ls /usr/games/r* src/r*
 
or anything involving 2 different directories, list will not work. It's
pattern matching algorythm is not good.
(Q: Why not put pattern matching into the global vector table? Then it
will work for all programs, including those non-BCPL ones that fake it)

		Michael Gersten
"Still waiting, after all these years" for real argument parsing.
      Views expressed here may not be those of the Computer Club, UCLA, or
  anyone in their left OR right mind.  And that's the name o' that tune.