Wednesday, February 23, 2011

Patching Things Up: TOS Ch 7

Since we have been dealing with bugs, we are now looking at the proper way to create and submit patches.  My group, The A-Team, had already looked through this chapter together in preparation for correcting our Sugar - Pippy bug, but we had not completed the text's exercises as directed yet.  Here is a summary of my experience with those exercises...

Exercise 7.2.2
This exercise is about exploring the diff command.  This command allows you to compare two files and find any changes or differences.  The basic format is diff <file1> <file2>.  There is an option with the diff command, -u, that changes the output.  Without this option the command only outputs what has been removed and what has been replaced.  When you include this option it includes a lot more information about the file and what lines were changed.  It actually includes the text of the file and shows the lines that have been removed and the lines that have been added in their context.  I can see how this extra information could be very helpful!  What if the line that was added to a file is simple x += 1;?  There is no context to help the programmer decide if this was a good change!

Exercise 7.8
The  wording in this exercise is actually rather confusing.  By the time I did this exercise I thought I was pretty comfortable with the concept of patches and using the diff command.  Actually, I would still hold to that assessment, but I didn't understand what I was supposed to create and compare.  After looking at the blogs of my classmates, I made a decision about what to do and here are my results.

The exercise says first to create a file, foo, with the contents bar.  So I started with creating a file, bar.txt, and placing a simple sentence in that file.  Then I used a unix command to copy the bar file into a file called foo.txt.  Finally, I created a patch file using the diff command in which I compared the empty file, /dev/null, with my foo file.  The contents of the patch show the contents of the file being added.  I'm still not sure that this is what the instructions intended, but it is what I did.

Exercise 7.9
This exercise asks us to create a patch on the echo command so that it echoes the words entered in reverse order.  It was pretty easy to follow the directions provided until I reached the end of them, where the instruction was to enter the code $ ./configure$ make, which simply gave me error messages because ./configure$ does not exist.  This turned out to be one of those silly mistakes that just requires a bit of space and some critical thought.  Apparently, when I started working on this assignment I was more tired than I thought because I simply didn't recognize that the '$' implied a new prompt and the make command is a familiar and separate command.  Like I said, one of those silly mistakes.  Fortunately for me I did not spend too much time fussing with it.  I chose to walk away and about an hour later had the unexpected epiphany!

Overall, this was an interesting a rather simple task.  It was actually kind of fun to play with patches.  This whole week or two has been very encouraging as we go forward with out projects!

No comments:

Post a Comment