| sp_mclaugh@yahoo.com 2007-02-16, 7:16 pm |
| Hi,
If I want to write my own shell, and have it be POSIX-compliant, is
there a standard regarding what types of syntax I have to support for
standard IO redirection? For example, the usual/common way to redirect
input and output of cat might look like:
cat <inFile >outFile
I think every shell supports switching the order of inFile and
outFile, at least. But what about something like this:
<inFile >outFile cat
<inFile cat >outFile
>outFile cat <inFile
I tried the above on Bash, and they work fine. But is it standard? I
know it's a (very) pedantic question, but I can't seem to find any
documentation on it.
----------------------
Oh, and to make it slightly more interesting, what if you throw pipes
into the picture? In other words, if the same line includes both
redirection and (multiple) pipes... is there a "standard" way to
handle how to behave if:
- the input redirection isn't placed after the first command
- the output redirection isn't placed at the very end
(either one could be at the beginning, end, or mixed in the middle)
Putting the redirection in the middle would be awful style by the
user, but... I guess I'd still like to have some shred of predictable
behavior for such users.
Thanks,
spmclaugh
|