Re: Redirection issue
- From: "Ed Prochak" <edprochak@xxxxxxxxx>
- Date: 30 Aug 2006 11:15:23 -0700
souissipro wrote:
Hi,
I have written a C program that does some of the functionalities
mentionned in my previous topic posted some days ago. This shell
should:
1- execute input commands from standard input, and also from a file
conatining the commands
2- does the redirection of the input and output from and to files.
3- retrieve the environment variables like HOME,..
I did the first question and it works fine, however when I modified the
code to implement the redirection it does not work anymore.
Could you please have a look to my code and tell me which is wrong
with?
I would also appreciate if you can tell me how to implement the 2nd
question in the function parse_line (see the code below):
Thank you very much for your help on this
Rather then us looking at your code, I have some general suggestions to
help you help yourself.
First: describe the problem.
the phrase "it does not work anymore" carries very little meaning.
"does not work" could be anything from not compiling, not executing,
crashing immediately, crashing the entire computer, and many other ways
of "not working". You have a case of berfore and after. What did it do
before that it does not do now? BE SPECIFIC. Properly defining the
problem often leads to finding the right solution.
Second: isolate the changes.
Run a diff on the current and previous versions of the program (You do
use a source control system don't you?) Determine how the changes could
have broken the code that was working. For example, look for global
variables with the same name as local variables. Watch for unterminated
block comments. Other common errors.
Three: trace your steps.
If you cannot figure it out from those ideas, try adding some debug
logging through the program OR run the program under a debugger.
Four: slash and burn.
If the problem is serious (e.g., crash and core dump) and nothing else
helps you isolate it, then start removing parts of code from the
current version until it no longer crashes, or you are back to the
previous working version. Cutting the body of functions, leaving only a
return, for example, may be useful.
You have a very good chance of finding the cause of this problem
yourself since you went from a working version to a non-working
version. You'll be a better programmer by learning how to find this
yourself. Just remember, the program is doing exactly what you told it
to do.
ed
.
- Follow-Ups:
- Re: Redirection issue
- From: souissipro
- Re: Redirection issue
- Prev by Date: Re: Redirection issue
- Next by Date: Re: operating with binary
- Previous by thread: Re: Redirection issue
- Next by thread: Re: Redirection issue
- Index(es):