Why is shell-setenv not working in tcsh?

Why is shell-setenv not working in tcsh?

There is no reason from what you’ve shown that the script would be executed in tcsh. The command setenv is not found because some different interpreter is executing the script. As further evidence the error messages are consistent with bash, dash and ksh’s error message formatting, but not with tcsh’s.

Which is the first line in a tcsh script?

A tcsh script should start with the line Add this line (it must be the very first line; note that the file must not have Windows line endings, so take care if you use a Windows editor, or better, use a Linux editor). Alternatively, if you prefer not to edit the file, you can invoke tcsh explicitly:

How to save files to a tcsh file?

I’ve made a tcsh file to save to a file the list of all files/folders in the folder it’s run (I’m working on a neuroimaging project, and I’m having the folder RawData containing a number of subjects each having a folder; I’ve written this file genSubjList.tcsh to save a list of subjects to the file subjList.txt). The code inside the file is:

How to use the foreach command in terminal?

The code inside the file is: When I change to the RawData directory in Terminal and write this piece of code in Terminal, it generates the list of the subjects without any problem, but when I call genSubjList.tcsh using source command:

Why is the syntax for if different in tcsh?

Syntax for if is different because tcsh has internal testing features, which standard bourne shell doesn’t have. In bourne shell testing is made using the external command test which has an alias [.

How to check the syntax of a bash script?

There is BashSupport plugin for IntelliJ IDEA which checks the syntax. If you need in a variable the validity of all the files in a directory (git pre-commit hook, build lint script), you can catch the stderr output of the “sh -n” or “bash -n” commands (see other answers) in a variable, and have a “if/else” based on that