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

11 messages
Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

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

Open this post in threaded view
|

 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 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 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-usersAlso: mailto:[hidden email]?subject=unsubscribe Reply | Threaded Open this post in threaded view | ## Re: Windows: where is the function _setargv() defined?  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-usersAlso: mailto:[hidden email]?subject=unsubscribe Reply | Threaded Open this post in threaded view | ## Re: Windows: where is the function _setargv() defined?  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-usersAlso: mailto:[hidden email]?subject=unsubscribe
 > 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-usersAlso: mailto:[hidden email]?subject=unsubscribe