Syntax for using multiline statements like an IF ELSE block

Hi,

I can’t fully understand the syntax in two cases:
1 - if not statement. For example I need to exclude windows OS then I try:

before_script:
  - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then 
      <some code>
    fi

but this doesn’t work

2 - I need to add dir to PATH env var within and out of if statement:

before_script:
  - if [[ "$TRAVIS_COMPILER" == "gcc" ]]; then 
      export PATH=$PATH:$CMAKE_INSTALL_PREFIX/lib;    # this works
    fi
    export PATH=$PATH:$CMAKE_INSTALL_PREFIX/bin;   # this doesn't work

could someone explain this? I can see the documentation about logical operators but it seems that it doesn’t cover my use cases…

My travis configuration file

1 Like

Thank you! good to know

I still can’t understand what is the syntax of if not equal expression…

before_script:
  - if [[ "$TRAVIS_OS_NAME" NOT EQUAL "windows" ]]; then 
      <some code>
    fi

The syntax is Bash.

1 Like

Wow, thank you a lot!
Such a tiny thing caused a lot time to spend…

Imprint