Mark is right, of course.

Keep in mind that you are not passing '?' to Rexx per se; you're 
passing it as the second argument to the shell, which reads the 
shebang line at the top of your script and forks a child shell to run 
the Rexx interpreter.

Meanwhile the shell has already processed the command line in many 
ways, not the least of which is to expand what it assumes are filename 
patterns into a list of explicit filenames ("file globbing").

In Unix shells, the '?' means "exactly one arbitrary character".  See 
the Wikipedia page "glob (programming)" for a table of the subtle 
differences of its interpretation across different platforms.

So your shell was looking for a matching filename of exactly one (or 
two or three) characters and provided the first one it found.  That's 
why you got different answers on different systems.

Just for grins and giggles, try

   $ set -o noglob
   $ rexx odd ??

and it should give you what you expected.

-Chip-

On 2/27/2014 11:55 AM Mark Miesfeld said:
>
> On Thu, Feb 27, 2014 at 8:34 AM, Maurice <maur...@bcs.org.uk
> <mailto:maur...@bcs.org.uk>> wrote:
>
>     Just come across weirdly inconsistent results when passing "?" as an
>     argument. What have I overlooked, I wonder...
>
>
> In most shells, including Windows, the ? is a file wildcard character.
>   You shouldn't try to pass it as an argument to a program.
>
>
>     Given the test program called 'odd':
>
>        #!  /usr/bin/rexx
>        parse arg given .
>        say "/"given"/"
>
>     then using  ooRexx-4.1.1.opensuse1140.i586.rpm on Linux Mageia-3, I
>     get the following inconsistencies between laptop and desktop machines
>     using the same version of ooRexx and Mageia-3:
>
>     Laptop:
>
>        $rexx ~/rx/odd ?
>        /?/
>        $ rexx ~/rx/odd ??
>        /rx/
>        ]$ rexx ~/rx/odd ???
>        /bin/
>
>     Desktop:
>
>        $ rexx ~/rx/odd ?
>        /A/                <-----------------Note!
>        $ rexx ~/rx/odd ??
>        /rx/
>        $ rexx ~/rx/odd ???
>        /bin/
>
>     Questions:
>        (1) With one "?", why do laptop and desktop yield different
>     results?
>
>
> You have different files in the rx directory on the different machines
> I would think.  On one you have a file A and on the other you have no
> single letter files.
>
>        (2) Why the unexpected results with strings of multiple "?"s?
>
>
> I'm not sure that they are unexpected. rx matches ?? It is a 2
> character file / directory name.
> ??? matches bin, it is a 3 character file / directory name.
>
> --
> Mark Miesfeld
>
>
>
> ------------------------------------------------------------------------------
> Flow-based real-time traffic analytics software. Cisco certified tool.
> Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
> Customize your own dashboards, set traffic alerts and generate reports.
> Network behavioral analysis & security monitoring. All-in-one tool.
> http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Oorexx-users mailing list
> Oorexx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
>

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to