This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: B19; supporting a DOS-path such as C:\a\b\c;C:\d\e\f;D:\g\h


[snip]
	 
> I have (and it is still available at one or more of the big DOS
> archives)
> a tool set and ksh compatible shell for DOS (16 bit and 32bit with DOS
> extender).  The author of this shell introduced an interesting
> feature,
> which perhaps could be used in bash.  He modified the shell to read a
> special setup file that contained a list DOS command names.  If I
> remember
> correctly, when the shell saw one of these names, it did no command
> line
> changes or substitutions but simply passed the whole line to cmd.com
> with
> the /c option.  It has been a while since I used it and I do not for
> sure
> recall if there may have been _some_ processing of the line (for
> $var's
> and backticks at least) but in general if backslashes were seen they
> were
> left as is and if forward slashes were used in a path, they were
> translated
> to backslashes.
> 
> You get the general idea, though, that the shell was changed to allow
> the
> co-existence of both types of commands.  Maybe this could also work
> for
> bash
> with the cygwin dll?
[Andrew Dalgleish]  
Hmm, to be done right, the "list of dos commands" would also need to
record which parameters are paths and which are just switch arguments.
(eg you would not want the /i in "FIND /i text c:\foobar.txt"
translated.)


If you really need to drop back to the cmd/command environment, here's a
workaround which doesn't require patching the shell.

1. Before starting BASH, save a copy of the current PATH in another
variable (I use DOSPATH). This is so you can run DOS tools without
searching the CygWin paths if you prefer.
2. Create a #!.exe which does absolutely nothing. (eg "int main() {
return 0; }")
3. From within bash, you can do this:

# Create a temporary batch file
cat >temp.bat <<eof
#! $COMSPEC /c
@echo off
REM restore the original DOS path (this step is optional)
set PATH=%DOSPATH%
REM run any DOS command or app
NMAKE /f foobar.mak
eof
# Execute the batch file 
# note - do not use a path here (cmd/command won't understand it), you
will need "." in $path.
temp.bat
# Remove the batch file
rm -f temp.bat

When bash sees the shebang line, it fires off cmd/command with the batch
file name.
When cmd/command runs the batch file it doesn't ignore the first line
(as most unix tools do), so it fires off the #!.exe (which does
nothing), then proceeds to execute the rest of the batch file.
Having "#!.exe" on your DOS search path also allows you to run the batch
file from outside the bash environment, but you may want to compile it
so it doesn't need the CygWin DLL.
One downside is that you see "#! C:\WINNT\system32\cmd.exe /c
foobar.bat" echoed, but I can live with that.

Regards,
Andrew Dalgleish

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]