Windows: where is the function _setargv() defined?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Windows: where is the function _setargv() defined?

Bill Modlin
Working on Windows 7, using the compiler included in a recent download of Code::Blocks.

I wrote a simple C command-line program.  It worked.

Now I am trying to write another.

It will process a series of arguments which may include "wildcard" characters "*" and "?".

It seems that something in the initialization process for argc and argv passed to main at startup is treating those arguments as files, and expanding the inputs to multiple argv entries for the files nominally referenced.

This is apparently done by a function _setargv().

I would like to include a version of _setargv() in my project that does not do the expansion.

Or alternatively I would be happy to find that there is some compiler switch or option than can disable the expansion for this project.

Assuming there is no such switch, I think I need source for _setargv(), either a version that does not do the expansion or one that I can modify to remove the expansion code.

Can anyone tell me where to get such source?  Google found me a couple of old versions that probably are not appropriate for my windows command line environment, but I cannot seem to find current code.  I tried downloading a few variants of "c library" packages, but none of them have this function included.  There are so many things on sourceforge and I am overwhelmed by all those versions and tars and whatnot... I thought I was trying to do something simple, but so far it seems anything but simple. 

If think that if I find or create such a version of _setargv() and include it in my project along with the code I am actually writing, that will solve my problem.  The compiler+linker will use my version and not look for the default version.  Someone please correct me if that assumption is wrong.  

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Eli Zaretskii
> Date: Mon, 14 Apr 2014 12:01:04 -0700 (PDT)
> From: Bill Modlin <[hidden email]>
>
> Working on Windows 7, using the compiler included in a recent download of Code::Blocks.
>
> I wrote a simple C command-line program.  It worked.
>
> Now I am trying to write another.
>
> It will process a series of arguments which may include "wildcard" characters "*" and "?".
>
> It seems that something in the initialization process for argc and argv passed to main at startup is treating those arguments as files, and expanding the inputs to multiple argv entries for the files nominally referenced.
>
> This is apparently done by a function _setargv().
>
> I would like to include a version of _setargv() in my project that does not do the expansion.
>
> Or alternatively I would be happy to find that there is some compiler switch or option than can disable the expansion for this project.
>
> Assuming there is no such switch, I think I need source for _setargv(), either a version that does not do the expansion or one that I can modify to remove the expansion code.
>
> Can anyone tell me where to get such source?

_setargv is defined in the Microsoft runtime library, so you cannot
include its source.

To disable globbing, put this one line in your sources:

     int _CRT_glob = 0;


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Bill Modlin
Eli, thank you for your response. 

Defining this variable does not fix the problem, but it still turns out to be useful.

It does not disable globbing, it just limits the globbing output to the first matching file.

Arguments containing wildcards are still replaced with a file name if any such is found for each.

I have discovered a way around that problem, by using GetCommandLine() to see what my user typed.

But I still want to use your _CRT_glob=0 suggestion, to avoid having setargv waste time and memory generating arguments that I will never look at.  Imagine that my user types something like:

MyProg * * * * * xxxx

in a directory with thousands of files.  Without your suggestion, it would spin for quite a while generating tens of thousands of useless arguments.  With it, it only generates 7.

GetCoommandLine() will allow me to write the program I wanted to write, and I'll probably leave it at that.

But it offends my sense of neatness to have setargv doing the unwarranted processing, even if it wastes only trivial resources.

You said that setargv is defined in the Microsoft runtime library.

Nevertheless I would think that I could still include a function of that name in my project sources, and if I did so I would expect the linker to use my definition of it and not call the external version.

Or am I missing something that would keep this from working?




-------------



> On Monday, April 14, 2014 5:13 PM, Eli Zaretskii <[hidden email]> wrote:
> >>  Date: Mon, 14 Apr 2014 12:01:04 -0700 (PDT)
>
>>  From: Bill Modlin <[hidden email]>
>>
>>  Working on Windows 7, using the compiler included in a recent download of
> Code::Blocks.
>>
>>  I wrote a simple C command-line program.  It worked.
>>
>>  Now I am trying to write another.
>>
>>  It will process a series of arguments which may include
> "wildcard" characters "*" and "?".
>>
>>  It seems that something in the initialization process for argc and argv
> passed to main at startup is treating those arguments as files, and expanding
> the inputs to multiple argv entries for the files nominally referenced.
>>
>>  This is apparently done by a function _setargv().
>>
>>  I would like to include a version of _setargv() in my project that does not
> do the expansion.
>>
>>  Or alternatively I would be happy to find that there is some compiler
> switch or option than can disable the expansion for this project.
>>
>>  Assuming there is no such switch, I think I need source for _setargv(),
> either a version that does not do the expansion or one that I can modify to
> remove the expansion code.
>>
>>  Can anyone tell me where to get such source?
>
> _setargv is defined in the Microsoft runtime library, so you cannot
> include its source.
>
> To disable globbing, put this one line in your sources:
>
>      int _CRT_glob = 0;
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Eli Zaretskii
> Date: Tue, 15 Apr 2014 02:21:02 -0700 (PDT)
> From: Bill Modlin <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
>
> Defining this variable does not fix the problem, but it still turns out to be useful.
>
> It does not disable globbing, it just limits the globbing output to the first matching file.
>
> Arguments containing wildcards are still replaced with a file name if any such is found for each.

That's not what I see on my system.  But maybe what you see is
specific to the latest version of the MinGW runtime.  I didn't yet
switch to that, as it has several annoying bugs that get in my way, so
I'm still using MinGW 3.20.

> You said that setargv is defined in the Microsoft runtime library.
>
> Nevertheless I would think that I could still include a function of that name in my project sources, and if I did so I would expect the linker to use my definition of it and not call the external version.

Unfortunately, this is not true, because the Microsoft runtime is in a
DLL, and the startup functions that were compiled and linked against
that DLL will still call the function in the DLL, even if you have its
namesake statically linked into your program.

What you expect is only true when a program is linked statically
against the runtime libraries, but that is only possible if you
compile your program with MSVC, since MinGW does not provide static
versions of the Windows runtime (they are not freely distributable,
AFAIK).

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Keith Marshall
In reply to this post by Eli Zaretskii
On 14/04/14 22:13, Eli Zaretskii wrote:

>> Date: Mon, 14 Apr 2014 12:01:04 -0700 (PDT)
>> From: Bill Modlin
>> [My program] will process a series of arguments which may include
>> "wildcard" characters "*" and "?".
>>
>> It seems that something in the initialization process for argc and
>> argv passed to main at startup is treating those arguments as
>> files, and expanding the inputs to multiple argv entries for the
>> files nominally referenced.
>>
>> This is apparently done by a function _setargv().

I guess you've found this documented on MSDN.  It may be so, in the case
of programs compiled with MSVC, but it is not so in the case of programs
compiled with MinGW.

> _setargv is defined in the Microsoft runtime library, ...

No, I do not believe this to be the case; running

    $ pexports msvcrt.dll | grep setargv

(on both Win7 and WinXP), shows no evidence of any such function in the
dynamic runtime library.  Rather, I suspect that it may be provided as a
free-standing start-up module for MSVC, such that users may do ...

> so you cannot include its source.

... precisely this, providing their own custom implementation, and so
achieve a change from the default behaviour of the MSVC start-up code.
However, doing so will have no effect for MinGW programs, because the
MinGW start-up code never calls _setargv(); it calls __getmainargs(), as
noted below, passing ...

> To disable globbing, put this one line in your sources:
>
>      int _CRT_glob = 0;

... whatever value may be assigned to this publicly visible global
variable; (if you don't define it yourself, mingwrt-3.x will supply a
default of 1, which enables globbing, while mingwrt-4.x will assume a
default of 2, which disables globbing in __getmainargs(), but then
performs it using an alternative algorithm, which circumvents known
inconsistencies, and ultimately broken behaviour, in Microsoft's
implementation).

Note that, while pursuing https://sourceforge.net/p/mingw/bugs/1621/, I
could find no evidence that __getmainargs(), which is called directly by
MinGW's start-up code, ever calls _setargv(); rather, I suspect that it
may work the other way around -- perhaps MSVC's start-up code calls
_setargv(), the default implementation of which (presumably) delegates
the call to __getmainargs().

--
Regards,
Keith.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

George Koehler
In reply to this post by Bill Modlin
On 4/15/2014 9:21 AM, Bill Modlin wrote:
> It does not disable globbing, it just limits the globbing output to the first matching file.
>
> Arguments containing wildcards are still replaced with a file name if any such is found for each.

I cannot reproduce this problem. I have gcc 4.8.1-4 with
mingwrt-4.0.3-1. In a test program, 'int _CRT_glob = 0;' prevents any
globbing.

Run your program from cmd.exe, not from bash or any MSYS shell. Bash
would do its own globbing before it runs your program.

=begin
#include <stdio.h>

int _CRT_glob = 0;

int
main(int argc, char **argv)
{
   int i;

   for (i = 0; i < argc; i++)
     printf("argv[%d]: %s\n", i, argv[i]);
   return 0;
}
=end

 >gcc showarg.c -o showarg
 >showarg *.c
argv[0]: showarg
argv[1]: *.c


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Keith Marshall
On 16/04/14 04:26, George Koehler wrote:
> Run your program from cmd.exe, not from bash or any MSYS shell. Bash
> would do its own globbing before it runs your program.

That may be avoided, if desired, either by quoting the globbable arguments:

   $ ./foo '*' ...

or by disabling shell globbing entirely:

   $ set -f
   $ ./foo * ...
   $ set +f

(or, if you prefer, by the equivalent):

   $ set -o noglob
   $ ./foo * ...
   $ set +o noglob

--
Regards,
Keith.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Bill Modlin
Update. Problem has evaporated, _CRT_glob works as expected. 


I cannot reproduce the strange behavior I observed before, when I saw an * being replaced by a single file name when I defined _CRT_glob = 0.


Then as now I was working from a CMD.EXE shell under Windows 7 pro, with admin privileges but nothing else special.

Then as now I was testing with a trivial program, something like this:


int _CRT_glob = 0;
int main (int argc, char **argv)
{
  printf("CRT_glob=%d, argc=%d\n",_CRT_glob,argc);

  if (argc > 10) argc = 10;
   while (argc--)
  {
    printf("%s\n",*argv++);
  }
   return(0);
}

If I left out the _CRT_glob definition or set it to 1, I would see normal behavior, with an * replaced by a list of all the files in the directory from which the program was called, potentially thousands of entries.

I don't have the original program with which I saw those results, since I modified it to try other things.

Now, new versions behave as they should, with _CRT_glob=0 properly suppressing the globbing function entirely, leaving my * as an *.  A baffling mystery to me, but nothing for others to worry about: logically I must have done something different no matter how hard that is for me to accept.

----
About escaping characters to bypass globbing:

The point of this program is to minimize keystrokes and forgive typing errors and mental lapses when bouncing around in a file system.  Having to remember to escape certain things somewhat defeats the purpose.

Normal usage is something like:

G:\EVERQUEST>g t foo r<ENTER>
F:\text utils\fooproject\release>

I could also have typed "g * foo r" and probably gotten to the same place, if I forgot completely where I might have put fooproject. 

If I specifically want to find the version on the J drive, I could try:
g j;* foo r<enter>

Note that ";" is accepted as an intended ":" for when I miss the shift key, which is more often than I want to admit. :)

----
About using a g.bat file to do the actual directory changes:

My g.bat file is:

@echo off
shift
cmdGO %*
%GO_DRIVE%
cd %GO_DIRECTORY%

cmdGO is the actual program, which finds the target directory and sets the proper environment variables.

----
Thanks for the help, I think _CRT_glob solves my problem, now I just need to write the cmdGO program.

I have no idea what I might have unknowingly done differently.  As I said, I cannot reproduce what I saw before and I can't imagine what one could do to produce that odd result.

Bill Modlin
 


> On Wednesday, April 16, 2014 3:56 AM, Keith Marshall <[hidden email]> wrote:
> > On 16/04/14 04:26, George Koehler wrote:
>>  Run your program from cmd.exe, not from bash or any MSYS shell. Bash
>>  would do its own globbing before it runs your program.
>
> That may be avoided, if desired, either by quoting the globbable arguments:
>
>    $ ./foo '*' ...
>
> or by disabling shell globbing entirely:
>
>    $ set -f
>    $ ./foo * ...
>    $ set +f
>
> (or, if you prefer, by the equivalent):
>
>    $ set -o noglob
>    $ ./foo * ...
>    $ set +o noglob
>
> --
> Regards,
> Keith.
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may
> cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:[hidden email]?subject=unsubscribe
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Raffaello D. Di Napoli-2
Hi Bill,

2014-04-16 11:24 GMT-04:00 Bill Modlin <[hidden email]>:

>
> About using a g.bat file to do the actual directory changes:
>
> My g.bat file is:
>
> @echo off
> shift
> cmdGO %*
> %GO_DRIVE%
> cd %GO_DIRECTORY%
>
> cmdGO is the actual program, which finds the target directory and sets the proper environment variables.

I’m afraid I have bad news for you - you can’t change environment
variables for the program that called yours.
What you want to do can only work in cmd.exe if you use some "for"
trickery to run the program, capturing its output, and parsing it into
a variable.
In Bash or any POSIX shell it’s much easier, of course: cd $(cmdGO "$@")

Also, you’ll probably want to use "cd /d %GO_DIRECTORY%" and not worry
about setting two separate variables for drive and path.

Hope this helps,
--
Raff

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Bill Modlin
Sigh.  I can have cmdgo write the needed change to a temporary .bat file that g.bat chains to.  Messy but it works.

There really should be a way to execute some code under the shell process, rather than launching a separate process.  Something like the primitive .com executables that used to work in DOS and the windows command shells before the new 64 bit version.  My previous version of this helper program was G.COM, written in 16-bit MASM many years ago.





> On Wednesday, April 16, 2014 12:27 PM, Raffaello D. Di Napoli <[hidden email]> wrote:
> > Hi Bill,
>
> 2014-04-16 11:24 GMT-04:00 Bill Modlin <[hidden email]>:
>>
>>  About using a g.bat file to do the actual directory changes:
>>
>>  My g.bat file is:
>>
>>  @echo off
>>  shift
>>  cmdGO %*
>>  %GO_DRIVE%
>>  cd %GO_DIRECTORY%
>>
>>  cmdGO is the actual program, which finds the target directory and sets the
> proper environment variables.
>
> I’m afraid I have bad news for you - you can’t change environment
> variables for the program that called yours.
> What you want to do can only work in cmd.exe if you use some "for"
> trickery to run the program, capturing its output, and parsing it into
> a variable.
> In Bash or any POSIX shell it’s much easier, of course: cd $(cmdGO
> "$@")
>
> Also, you’ll probably want to use "cd /d %GO_DIRECTORY%" and not worry
> about setting two separate variables for drive and path.
>
> Hope this helps,
> --
> Raff
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may
> cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:[hidden email]?subject=unsubscribe
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Windows: where is the function _setargv() defined?

Eli Zaretskii
> Date: Wed, 16 Apr 2014 16:05:17 -0700 (PDT)
> From: Bill Modlin <[hidden email]>
>
> Sigh.  I can have cmdgo write the needed change to a temporary .bat file that g.bat chains to.  Messy but it works.

You could use one of the forms of the FOR command:

  FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

It's a bit clumsy, and it has a few limitations (e.g., if you need
some fancy redirection in `command`), but it does work.  See "for /?"
for more details.

> There really should be a way to execute some code under the shell process, rather than launching a separate process.  Something like the primitive .com executables that used to work in DOS and the windows command shells before the new 64 bit version.  My previous version of this helper program was G.COM, written in 16-bit MASM many years ago.

I don't think .com programs on DOS did anything special in this
regard.  What you miss is the global system-wide current directory
that you had on DOS.  You cannot possibly have that in a modern
multi-process OS.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe