On Fri, Feb 28, 2014 at 9:29 AM, Staffan Tylen <staffan.tylen@gmail.com> wrote:
Sorry to jump in here but please help me understand: which statement in the rexx program is it that invokes the shell so that it starts looking for matching file names? In the code that I saw there was only a say statement so I don't understand what's going on.

No statement in the Rexx program invokes the shell.  It is this line:

$rexx ~/rx/odd ?

typed on the command line that <invokes> the shell.  Although invokes is not really a good word.  The shell has already been invoked and is sitting in a loop parsing stuff that is typed on the command line.

The shell determines that odd is a file name and an executable file at that, uses the shebang line to determine the rexx executes the file.  It then passes the file name and the command line arguments to rexx.

As Chip said, the command line parsing does a lot, and I'm sure different shells do it in different order.  But most, if not all, shells expand file name patterns and pass each individual, expanded, file name as arguments to the executable.

In the program:

#!  /usr/bin/rexx
  parse arg given .
  say "/"given"/"

Maurice drops everything after the first word in the argument list.  But there could theoretically be many file names passed into the program.  At least for ???.  We see bin, but that could be followed with cat, dog, fog, hhh, and so on.

Mark Miesfeld