Author: Stan Eisenstat
Subject: Re: [Cs323] ex
Date: Friday, 25 Sep 2020, 08:50:49
> Message Posted By: Unknown
>
> If we do:
>
> (1)$ a b c >d e f g
>
> Why is the output for argv[5]:
> argv[5] = g >d
Because "g" is the fifth argument and stdout was
redirected to "d". [Note the extra space between
"g" and ">d".]
=====
> What part of the rule makes >d go to the very end. From my understanding,
> if we are in the suffix, and read a TEXT, we then try to read as many TEXT
> and we can and then try to Read as many Redirect as we can? Or, is it
> because once we see >d, we keep reading the texts e f g as argv's to the
> left of >d?
Your first explanation is correct.
What is printed is a representation of the CMD tree,
which is produced by an in-order traversal that shows
* the depth of the each CMD struct,
* the type of that node,
* a list of the arguments, and
* any redirections (in the order <, > or >>, 2> or 2>>
or &>, and <<, the last on a separate line).
=====
> I get that the >d is supposed to be with g, but how the grammar get us to
> output this correctly.
parse() generates the CMD tree; dumpCMD() (which is in
Hwk2/mnainParsley.c) prints it as described above.
--Stan-
PREV
INDEX
NEXT