Computing.Net > Forums > Unix > skipping steps on a KornShell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

skipping steps on a KornShell script

Reply to Message Icon

Name: Cristina
Date: July 18, 2002 at 07:27:56 Pacific
Comment:

Does exist in kornshell a command like DOS "goto" to skip some steps and go to a determinated place on a script?
Could somebody tell me if there's way with if then sentences to do that (for exemple
if [ $var1 = 1 ]
then
echo "step will be skipped"
goto "there"
fi

Please help



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: July 18, 2002 at 08:15:52 Pacific
Reply:

Check out http://www.kornshell.com/

I looked thru the Korn 93 manual and did not see a goto command listed.

In school, most programmers are trained not to use goto as it leads to bad programming practices.

Most (99.999%), if not all, code can be coded without any gotos.

If you need some help with that, post some code.


0

Response Number 2
Name: LANkrypt0
Date: July 18, 2002 at 14:04:40 Pacific
Reply:

My Suggestion:
Make all of your chunks of code functions, and then you can call those functions. (i.e):

#!/bin/ksh
stty erase ^?
function echoyes {
echo "yes"
}
function echono {
echo "no"
}
echo "Do you like monkeys?"
read answer
case $answer in
y*|Y*)
echoyes
;;
n*|N*)
echono
;;
*)
ksh testscript
;;
esac

NOTE: Anything can go between the { }'s for functions, and then you can call those anytime during the regular routine of your script. The functions will act as mini-programs themselves. So you can have hundreds or "mini-programs" within your main program.

Hope this helps, any other questions, feel free to ask.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: skipping steps on a KornShell script

Need Help with KornShell script www.computing.net/answers/unix/need-help-with-kornshell-script/5978.html

Kornshell script help is needed www.computing.net/answers/unix/kornshell-script-help-is-needed/4726.html

A simple script for creating a link www.computing.net/answers/unix/a-simple-script-for-creating-a-link/6981.html