Search code examples
macosshellzsh

Shell script - using source command with if statement


I have a script which using if statement as below:

if [ "$_nowTime" \> "$_authExpiration" ]; then
    echo "Your last token has expired"
    promptForMFA
  fi

when I run it via "source" or "'" command I get an error "condition expected: >", seems like the source doesn't like the backslash, in case I remove it, it treat it as a pipe and create a file.


Solution

  • Solved by adding another square: if [[ "$_nowTime" > "$_authExpiration" ]]