Parsed command info

Skip to first unread message

Iron Spring Software

Apr 1, 2021, 2:41:27 PMApr 1
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.

Ian Stewartson

Apr 1, 2021, 4:38:58 PMApr 1

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: (I found a copy under https://ftp- 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.

Dave Yeo

Apr 2, 2021, 1:50:43 AMApr 2
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 Yeo

Apr 2, 2021, 2:03:56 AMApr 2
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.

Peter Flass

Apr 2, 2021, 3:24:40 PMApr 2
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.

Reply all
Reply to author
0 new messages