The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Password cannot be circular shift of logonid sag71155 HP-UX 2 05-09-2008 02:04 AM
Reference: WebObjects 5.4.1 Reference iBot UNIX and Linux RSS News 0 03-11-2008 05:50 PM
Reference Variable cchaloux Shell Programming and Scripting 18 10-03-2007 06:58 AM
How to reference a variable within sed? rockysfr Shell Programming and Scripting 1 06-27-2007 01:04 AM
Reference Material chrisc@nwark.ne HP-UX 0 09-30-2006 05:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-01-2006
Registered User
 

Join Date: Dec 2005
Posts: 49
Circular reference

I might know the answer to this, but I just want to see if any of you know any work arounds before I go and re-write the whole thing.

I have a script as follow:
Code:
$ cat testing
#! /usr/bin/ksh

f ()
{
        echo "Type \"y\" \c"
        read value

        if [ "$value" = "y" ];
        then
                echo "Circular reference."
                f
        fi

        echo "Running.."
}
f
As you can see, it has a circular reference to the function on which its call if I input a value of "y" when it ask me. And I execute it..
Code:
$ ./testing
Type "y" y
Circular reference.
Type "y" y
Circular reference.
Type "y" n
Running..
Running..
Running..
$
Which I expect to be "normal". Now, my question is, is there anyway, I can avoid this without re-writing the whole thing? I mean, can I, somehow especify to it it should "halt" its old executions when I tell it to jump again to the function.

Any help would be appreciated. If anyone has done any similar, I am open for suggestions.

Thanks!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-04-2006
Registered User
 

Join Date: Dec 2005
Posts: 49
Ok, I got it solved: I just had to include the keyword return.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0