On 8/8/2016 10:33 AM, Corinna Vinschen wrote: > On Aug 8 09:43, cyg Simple wrote: >> As for PATHEXT we can do the following scenario instead. >> >> export PATHEXT="$PATHEXT;.TXT" >> vi foo.txt >> :set ff=dos >> i >> a >> b >> c >> <ESC> >> :wq >> cmd /c foo > > As you show here, the PATHEXT definition is so that it also contains > file suffixes which require to know the interpreters starting them. To > implement that, the lib would have to either read the registry to know > the connection between suffix and interpreter (which is pretty > convoluted), or it would have to "start the file", aka call ShellExecute > on the file, without knowing what process will come up as child process. > In your example that would be Notepad or Write. > > The way this works is just not feasible to be used from inside the DLL, > e.g.: > > - ShellExecute does not return a handle to the called process, so the > parent can't wait(2) for it. > > - ShellExecute does not allow to specify an environment for the child > process. Cygwin's Windows environment is reduced to minimal size. > Cygwin children inherit the POSIX environment by a simple copy > process. Only when starting a non-Cygwin process, this process gets > a full Windows environment by means of the matching CreateProcess > parameter. >
Sorry, it seems I confused the issue. I was suggesting with this example that as a Cygwin shell user I could use this technique to start a file if I so choose without any modification to Cygwin. > So, if we actually implement PATHEXT, its usage would be limited to > suffixes of binary files and files starting with #!<interpreter>, or we > would have to use a way to start an application which doesn't work well > in a POSIX scenario, or we would have to search the registry for the > suffix linkage. Additionally to searching a variable number of files > for each single file access. I tried "chmod +x foo.txt; ./foo.txt" but that results in Cygwin assuming the text file is a script and executing each line of the file. If PATHEXT were used only to determine that the file should be passed to ShellExecute instead it might be beneficial but since I can easily just do "cmd /c foo.txt" then probably not so much. > > Additionally I would (again?) like to stress that PATHEXT is a feature > of CMD, aka, the shell. It's not a feature of the underlying libs. And other application type programs and libraries. WSH for one makes use of PATHEXT. https://msdn.microsoft.com/en-us/library/fd7hxfdd(v=vs.84).aspx -- cyg Simple -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple