How to Make an If-Else in Csh Script

I'm trying to make an if-else in csh script but it is not working:

do you know why this is not working?

if($2 == "rx" && $3 == "2") then
  setenv project_name       "mipi_2_rx_core_ns"
  setenv synth_logfile_name "mipi_2_rx_core_ns_syn"
  echo "RX 2 lanes"
  endif
  else if ($2 == "rx" && $3 == "4")
    setenv project_name       "mipi_4_tx_core_ns"
    setenv synth_logfile_name "mipi_4_tx_core_ns_syn"
    echo "RX 4 lanes"
endif
  else if ($2 == "plldig")
    setenv project_name       "dphyplldig"
    setenv synth_logfile_name "dphyplldig_syn"
  endif  
  else
    echo "No options specified"

endif
3

1 Answer

See the if else placement. You are missing then after ifs

#!/bin/csh

if ($2 == "rx" && $3 == "2") then
    setenv project_name       "mipi_2_rx_core_ns"
    setenv synth_logfile_name "mipi_2_rx_core_ns_syn"
    echo "RX 2 lanes"
else if ($2 == "rx" && $3 == "4") then
    setenv project_name       "mipi_4_tx_core_ns"
    setenv synth_logfile_name "mipi_4_tx_core_ns_syn"
    echo "RX 4 lanes"
else if ($2 == "plldig") then
    setenv project_name       "dphyplldig"
    setenv synth_logfile_name "dphyplldig_syn"
else
    echo "No options specified"
endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest