Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Bash: If statement with dash o

Options
  • 23-04-2019 11:57am
    #1
    Registered Users Posts: 5,531 ✭✭✭


    Hi, can anyone deduce what the if statement means below, specifically the "ash o" parts. That argument doesnt exist in the man page for "test" or "if".
    check_params()
    {
    if [ ! "${PATH}" -o ! "${ACTION_TYPE}" -o ! "${LU_PATH}" ]; then
        usage_msg
        exit 1
    fi
    }
    


Comments

  • Registered Users Posts: 7,500 ✭✭✭BrokenArrows


    its an argument to whatever executable is being executed.
    The ! takes the last argument from the console history and puts it in there.

    So what it does really depends on what is being executed in the history.


  • Registered Users Posts: 1,109 ✭✭✭Skrynesaver


    $ if [ 1 -eq 1 -o 2 -gt 3 ] ; then echo OK;fi
    OK
    
    $ if [ 1 -eq 0 -o 2 -gt 3 ] ; then echo OK;fi
    
    $ if [ 1 -eq 0 -o 2 -gt 1 ] ; then echo OK;fi
    OK
    

    It's the equivalent of an OR


  • Registered Users Posts: 2,415 ✭✭✭Singer


    $ if [ 1 -eq 1 -o 2 -gt 3 ] ; then echo OK;fi
    OK
    
    $ if [ 1 -eq 0 -o 2 -gt 3 ] ; then echo OK;fi
    
    $ if [ 1 -eq 0 -o 2 -gt 1 ] ; then echo OK;fi
    OK
    

    It's the equivalent of an OR

    Yep. The Advanced Bash Scripting Guide has been my go-to guide for this stuff for... too many years:

    http://tldp.org/LDP/abs/html/comparison-ops.html


  • Registered Users Posts: 5,531 ✭✭✭veryangryman


    Thanks guys. Very helpful


Advertisement