1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomato scripting - "goto" construction

Discussion in 'Tomato Firmware' started by Mihail_, Oct 22, 2010.

  1. Mihail_

    Mihail_ Networkin' Nut Member

    Hello, i'm interested to know, is that possible to use "goto" construction on tomato? or functions in script with global variables? Could you give some examples?
    something like
    Code:
    i=0
    goto mark
    echo $i
    
    :mark
    i=$((i+1))
    or

    Code:
    i=0
    static_plus
    echo $i
    
    function static_plus {
    i=$((i+1))
    }
    thanks in advance!
     
  2. srouquette

    srouquette Network Guru Member

    Take a look at the script in my sig, function call with global variable.
    I suppose the problem, in your second code, is in the function.
    Code:
    i=$(($i+1))
    $(( )) means it should interpret the expression.
     
  3. Mihail_

    Mihail_ Networkin' Nut Member

    thanks a lot!

    2all
    functions must be at the top of the script and contain brackets after the name without any declares like "function"..

    Code:
    i=0
    
    static_plus() {
    i=$(($i+1)) 
    }
    
    static_plus
    echo $i
    i=$((i+1)) works too, but i think it is incorrect
     
  4. ~nephelim~

    ~nephelim~ LI Guru Member

    Probably goto is not available in tomato's bash shell.

    Using functions would be the way to go even if goto were to be available.
     

Share This Page