LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-22-2002, 06:07 AM   #1
sobchak
LQ Newbie
 
Registered: Jul 2002
Posts: 1

Rep: Reputation: 0
GOTO function in bash?


Hello, I don't know hardly any bashscripting at all, so bear with me.

Is there an equivalent of the DOS function GOTO in bash? What I want is to put a "label" somewhere in the code, and be able to jump back to that location.

Example:

I have a command that exits with status 0, and if it does not, I want to run the program from the top again. I know how to write the if-statement, but not how to go back to a certain location in the code.

Any suggestions?
 
Old 07-22-2002, 06:10 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
goto functions were banned in decent programming languages many years ago as they really don't make sense and can be lethal. make a function instead

function() {
script here
}

and call it in a conditional block
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH goto dkrysak Programming 35 03-21-2013 11:22 AM
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 11:15 AM
can you use goto in bash script sabliny Programming 3 10-07-2005 06:54 PM
Bash function pazvant Linux - Software 1 03-08-2005 08:47 AM
How do I add a function to Bash? Gag Halfrunt Linux - Newbie 5 11-25-2004 01:05 PM


All times are GMT -5. The time now is 06:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration