Sponsored Content
Full Discussion: help please
Top Forums Shell Programming and Scripting help please Post 13372 by LivinFree on Wednesday 16th of January 2002 06:13:20 AM
Old 01-16-2002
The first thing I can suggest is to make your code more organized. Just looking at this (with line numbers and all - even though we're missing the first 40-some lines) makes my eyes want to roll back in my head...
You can do it to fit your own style, but indenting can be your friend - for example:
Code:
(...)
read dir junk
if [ -d "$dir" ]; then
        echo "The \"$dir\" directory is valid."; cd $dir
        echo "You are now in `pwd`"
else
        echo "The \"$dir\" directory is not valid"
        echo "You are still in `pwd`"
fi
(...)

I don't know about you, but that's way easier for me to read... It groups each step together, so you can pretty much see what's going on in a glance.

Right now I am assuming this is homework, so I'm not going to give anything away - especially using somethng you may or may not have learned yet. But here's a hint for looping in a menu script (besides the ones mentioned other places in the forum):
use a "while" construct, and tell it to loop (almost) forever... that way, at the end of the command, it simply restarts.

Hope it helps.
 
All times are GMT -4. The time now is 07:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy