Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:40:07+00:00 2026-06-05T06:40:07+00:00

I am currently converting a csh script on linux to a bash script on

  • 0

I am currently converting a csh script on linux to a bash script on Mac OS X lion.

The csh script looks like:

setenv CNS_SOLVE '/Users/ucbthsa/Documents/haddock2.1/software/bin/'
setenv CNS_SOLVE $CNS_SOLVE
if ( -d $CNS_SOLVE ) then
    if ( ! $?CNS_ARCH ) setenv CNS_ARCH `$CNS_SOLVE/bin/getarch`
else
    setenv CNS_ARCH 'unknown'
endif

My conversion to a Mac bash script looks as follows:

export CNS_SOLVE='/Users/ucbthsa/Documents/haddock2.1/software/bin/cns_solve_1.3'
export CNS_SOLVE=$CNS_SOLVE

if [ -d $CNS_SOLVE ]; then
  if [ ! $?CNS_ARCH ]; then
    export CNS_ARCH='$CNS_SOLVE/bin/getarch'
else
  export CNS_ARCH='unknown'
endif

When I try and source the Mac bash script I get the following error:

-bash: cns_solve_env: line 10: syntax error: unexpected end of file

I cannot understand why I am getting this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:40:08+00:00Added an answer on June 5, 2026 at 6:40 am

    You should use fi rather than endif and you aren’t closing the first if at all:

    export CNS_SOLVE='/Users/ucbthsa/Documents/haddock2.1/software/bin/cns_solve_1.3'
    export CNS_SOLVE=$CNS_SOLVE
    
    if [ -d $CNS_SOLVE ]; then
      if [ -z $CNS_ARCH ]; then
        export CNS_ARCH="$CNS_SOLVE/bin/getarch"
      fi
    else
      export CNS_ARCH='unknown'
    fi
    

    *edit: changed the second test, as William Pursell pointed out, it wouldn’t work as it was in bash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently in the process of converting an old bash script of mine into
I am currently scraping some data from the internet and converting into xml documents.
I am currently converting a Windows Phone 7 application to its web counterpart. The
I am currently converting a Windows Form application to ios. The windows implementation uses
I'm currently converting a test class which extended the Spring class AbstractTransactionalSpringContextTests to Spring
I'm currently converting some legacy code to create PDF files using iTextSharp. We're creating
I'm currently working on a project where I'm converting database info to java objects,
I'm currently having an issue wrapping my brain around the notion of converting my
I'm currently building a converter in C#. My program is converting from/to Decimal, Binary
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.