LinuxQuestions.org
Visit Jeremy's Blog.
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, 05: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, 05:10 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
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 10:22 AM
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
can you use goto in bash script sabliny Programming 3 10-07-2005 05:54 PM
Bash function pazvant Linux - Software 1 03-08-2005 07:47 AM
How do I add a function to Bash? Gag Halfrunt Linux - Newbie 5 11-25-2004 12:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:33 AM.

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
Open Source Consulting | Domain Registration