2

I have just installed Intel Parallel Studio and would now like to set up system variables, so Terminal can find the compilers etc.

In the installation guides tell me to run some included set-up scripts or include them in my bash profile etc. That's cool.

It always says though, for example:

Set the environment variables before using the compiler. You can use the source command to execute the shell script compilervars.sh or compilervars.csh.

However it doesn't explain the difference between the two variants anyway. I also am unable to find any comparisons of the two file extensions anywhere else online.

The only things I might infer is that the .csh files are Mac OSX specific, from the line:

On Linux* and OS X*, the file is a shell script called compilervars.sh or compilervars.csh

I would like to know more details before running anything.

  • If your login shell is bash or a bash compatible variant, run the .sh file. If your login shell is tcsh or another c shell, run the .csh file. The only relevant differences for the Intel scripts are how environment variables are set in the different shells. – casey Apr 22 '17 at 1:06
5

.sh is indicative of a script for the Bourne shell (sh) or the Bourne Again shell (bash), which is generally a superset of its predecessor.

.csh is indicative of a script for the C shell (csh), which, being a shell, is largely similar, but significantly different as soon as you start doing anything much more complex than running a series of static commands.

Both shells are generally available on any POSIXy environment, and indeed both are often preinstalled, though bash (and its cousin sh) are a little more ubiquitous in my experience.

I say 'indicative' above, because the idea of a file extension doesn't technically exist and has no semantic or syntactical meaning. A file could be named script.steve or documentation.exe or include.h and still actually be a shell script. For more definitive confirmation, look at the first line of the file. For a script designed to be executed directly, it should start with a shebang line, which starts with an octothorpe (#), a bang (!), and the path to the executable which should run the script. For example:

#!/usr/local/bin/bash

or

#!/usr/bin/python3
  • 1
    So in essence: use the .sh version if your login shell is an sh shell (bash, ksh) and use the .csh version if your login shell is a csh shell (csh or tcsh). On macOS, the default shell is a sh shell nowadays. – Kusalananda Apr 21 '17 at 20:26
  • Thanks! I saw that I can run man sh to get the details of my default shell. I got back that it is dash. I also ran man bash and received a bash man-page. Which one is being used by default and is there any difference I should care about? I am clearly a beginner - doing nothing complex, as you mentioned. [I am on Ubuntu 16.04]. – n1k31t4 Apr 21 '17 at 20:28
  • @DexterMorgan Both are sh shells. The default shell on Ubuntu is bash. – Kusalananda Apr 21 '17 at 20:30
  • 3
    @DexterMorgan man sh won't give you the manual of your default shell. It will give you the manual of whatever shell is being used as sh on your system. On Debian-based systems (Debian, Ubuntu, Mint etc) that is dash by default. However, your default shell is usually set to bash, not sh. To see the name of your default user's shell, run echo $SHELL. – terdon Apr 21 '17 at 20:30
  • Yep, as you said it would be: echo $SHELL returns /bin/bash/. Thanks @terdon! – n1k31t4 Apr 21 '17 at 20:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.