Shell script debug (Fwd)

Paul_Melson@keykertusa.com Paul_Melson@keykertusa.com
Thu, 5 Jul 2001 13:34:23 -0400


Matt must've hit 'r' instead of 'g' and sent this only to me. 

-----------------------------------------------------------------
Paul_Melson@keykertusa.com wrote:
> >I may just be stupid, but I wrote this little script, which I have 
> probably
> >done wrong, but if anyone out there can help point me in the right
> >directions, I'd really appreciate it.
[snipp]

A very handy thing to do when debugging bash scripts is to put "set -x" at 
the
top of the script.  This will give you feedback.  LOTS of feedback.  Of
course, sometimes it's completely useless, but that's what happens in
debugging.

If you're making a script with a DOS editor and the lines end with \r\n
instead of \n , bash will be very unhappy.  "dos2unix" can take care of 
that.

Also, did you know about the -p option to mkdir?  Using that, I can do
something like "mkdir -p ~/temp/wibble/foo" instead of "mkdir ~/temp ; 
mkdir
~/temp/wibble ; mkdir ~/temp/wibble/foo".


-- 
Matt G / Dances With Crows
There is no Darkness in Eternity/But only Light too dim for us to see
"I backed up my brain to tape, but tar says the tape contains no data...."