Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Parsed command info

5 views
Skip to first unread message

Iron Spring Software

unread,
Apr 1, 2021, 2:41:27 PM4/1/21
to
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

unread,
Apr 1, 2021, 4:38:58 PM4/1/21
to
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.

Dave Yeo

unread,
Apr 2, 2021, 1:50:43 AM4/2/21
to
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

Dave Yeo

unread,
Apr 2, 2021, 2:03:56 AM4/2/21
to
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

Peter Flass

unread,
Apr 2, 2021, 3:24:40 PM4/2/21
to
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
0 new messages