Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!dalcs!dalegass From: dalegass@dalcs.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: stupid COMMAND.COM (WAS: DOS enviroment size) Message-ID: <2438@dalcs.UUCP> Date: Thu, 12-Mar-87 15:32:25 EST Article-I.D.: dalcs.2438 Posted: Thu Mar 12 15:32:25 1987 Date-Received: Fri, 13-Mar-87 05:45:07 EST References: <2091@ncoast.UUCP> <409500003@prism> <2986@iuvax.UUCP> <12572@watnot.UUCP> Organization: Dept. of Math., Stats & C.S., Dalhousie University, Halifax, N.S., Canada Lines: 37 Keywords: DOS environment substitutions Summary: COMMAND.COM doesn't do the redirection In article <12572@watnot.UUCP>, djfiander@watnot.UUCP writes: > >> it is physically impossible to > >> pass certain characters to a program on the commandline, specifically > >> " ' * ? | etc. > > ^ ^ ^ ^ ^ > >I wrote a quicky C program which contained just printf("%s\n", argv[1]); > >I could pass all of those characters highlighted above and also < and >. > >The only thing I had to do is enclose | < and > in double quotes. ... > > This is for PC-DOS 3.1 on an IBM PC XT. > > Oops, * and ? are passed inside double quotes (sorry), but under DOS > 3.0 the others are still not passed. I know this because I tried to > use '|' in an egrep pattern. DOS passed the first part of the pattern to > egrep and tried to execute the second part. > I'm pretty sure that DOS does not do all of the redirection. Of course it handles redirection for it's own built-in commands (COPY,ECHO,etc.) but as far as executables go, they must do the work themselves. Most (if not all) C compilers will automatically handle this for you in their startup routine (which allocates memory, initializes channels, and so on). I've seen the source code for Aztec C, and redirection is taken care of from the program which is executed, and is not a trapping at the DOS level. This means that different C compilers might parse the " character a bit differently; hence the discrepancy between results. The C compiler which Microsoft used for their transient (.com .exe) commands could very likely perform a bit differently from a program compiled by another version of C. When DOS gives control to a .com or .exe file, it simply passes the whole command line to it, and let's it do what it wishes with the info. I think, however, that piping '|' *is* intercepted at the DOS level, whereas the '>' and '<' redirections are not. -dalegass@dalcs