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! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Bourne Shell scripting help

  • 04-06-2009 3:52pm
    #1
    Closed Accounts Posts: 752 ✭✭✭


    Checking an enviroment variable is set

    What i can do simply in bash with
    if [ -z $ENV_VER ] ; then



    i have tied this on borne and cant get it to work wothout


    "sh: ENV_VER: Parameter not set."


    I have tried:(what i can remember trying)

    if [-n ${var:-x}]

    [ ! -z $var ] && echo "set" || echo "not"

    ${var:-'SomeDefault'}

    if [ "X${VAR}" != "X" ] ;then echo "hi" ;fi;


Comments

  • Registered Users, Registered Users 2 Posts: 4,235 ✭✭✭bullpost


    If you're still stuck I think you can use the test command to do this iirc.

    Look up the man page for test but it should be something like:

    if test $A then ......


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    You sure
    if [ "X${VAR}" != "X" ] ;then echo "hi" ;fi;
    doesn't work?

    As is, it would only display "hi" when the VAR is set! Rather than when it is empty as you initially said. But I'm guessing that is a typo?
    if [ "X${VAR}" == "X" ] ;then echo "hi" ;fi;
    to say "hi" when VAR is not set

    A great way to test this things I find is to enabling debugging with set -x

    set -x
    if [ "X${VAR}" == "X" ] ;then echo "hi" ;fi;

    then at the prompt
    $ export VAR= (just to be sure!)
    $ ./script.sh
    ++ ''
    ++ echo hi
    hi

    $ export VAR=yes
    $ ./script.sh
    ++ ''


  • Closed Accounts Posts: 752 ✭✭✭JimmyCrackCorn!


    [ -z $A'' ]

    Works


Advertisement