• Parsed command info

    From Iron Spring Software@21:1/5 to All on Thu Apr 1 11:41:24 2021
    Is there a way to get a fully-parsed command line, with wildcard
    expansions, etc. from command.exe? For PL/I I have been using the
    command as typed from pib_pchcmd as the parm to the main procedure, but
    for compatibility with unix I'd like to also get argc and argv.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ian Stewartson@21:1/5 to Iron Spring Software on Thu Apr 1 20:38:57 2021
    Iron Spring Software wrote on 01 Apr 2021:

    Is there a way to get a fully-parsed command line, with wildcard
    expansions, etc. from command.exe? For PL/I I have been using the
    command as typed from pib_pchcmd as the parm to the main procedure, but
    for compatibility with unix I'd like to also get argc and argv.


    Peter,

    If you can find a copy of the UNIX Shell I ported/wrote for MS-DOS (but
    also got to work on OS/2, WinNT), there is a source file in there which
    may help you. You need: ms_sh23s.zip (I found a copy under https://ftp- os2.nmsu.edu/download/pub/os2/util/shell/ of all places). The main
    source is a replacement for stdargv - stdargv.c, but you may need some of
    the other files (director.c, etc.). I've not looked at this for over 15
    years, but at the time, I used it by replacing the MS/IBM object in the approach library. Whether it still works, I've no idea - not really used
    OS/2 for years.

    From memory, the only this I did was compile it, replace the version in
    the library and then any executable built using that library did a unix-
    like command line expansion - it even handled quotes. Only thing to
    beware of it that it uses UNIX directory separators and backslashes as
    escapes. From memory, OS/2 worked with either / or \ as the directory separator, but I may be wrong. In which case, it's left as an exercise
    for the keen student to covert appropriately.

    Hope this helps.
    Regards
    Ian.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dave Yeo@21:1/5 to Iron Spring Software on Thu Apr 1 23:03:55 2021
    On 04/01/21 10:41 AM, Iron Spring Software wrote:
    Is there a way to get a fully-parsed command line, with wildcard
    expansions, etc. from command.exe? For PL/I I have been using the
    command as typed from pib_pchcmd as the parm to the main procedure, but
    for compatibility with unix I'd like to also get argc and argv.

    Seems most compilers libc should have a function to do that, for
    example, with GCC you can call _wildcard (&argc, &argv) at the beginning
    of main to expand wildcards, there's also _response (&argc, &argv) for expanding response files.
    cmd.exe itself doesn't expand wildcards.
    Dave

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dave Yeo@21:1/5 to Ian Stewartson on Thu Apr 1 22:50:40 2021
    On 04/01/21 12:38 PM, Ian Stewartson wrote:
    From memory, OS/2 worked with either / or \ as the directory
    separator, but I may be wrong.

    cmd.exe does not like / as a directory separator, other programs can get confused unless the PATH starts with a drive letter, is that / a
    directory separator or a parameter. Most of OS/2 internally doesn't seem
    to care.
    Dave

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flass@21:1/5 to Dave Yeo on Fri Apr 2 12:24:39 2021
    Dave Yeo <dave.r.yeo@gmail.com> wrote:
    On 04/01/21 10:41 AM, Iron Spring Software wrote:
    Is there a way to get a fully-parsed command line, with wildcard
    expansions, etc. from command.exe? For PL/I I have been using the
    command as typed from pib_pchcmd as the parm to the main procedure, but
    for compatibility with unix I'd like to also get argc and argv.

    Seems most compilers libc should have a function to do that, for
    example, with GCC you can call _wildcard (&argc, &argv) at the beginning
    of main to expand wildcards, there's also _response (&argc, &argv) for expanding response files.
    cmd.exe itself doesn't expand wildcards.
    Dave


    Yes, apparently. I was thinking that COMMAND.EXE was the equivalent of a
    shell, but I guess it’s up to every application to parse the argument and expand wildcards, etc. As you say, LIBC has a routine for this, but I
    don’t want to call C routines from PL/I because calling one routine brings
    in the whole boatload of cruft.

    --
    Pete

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)