How can I get the shell-script-mode in Emacs to intepret #PBS -S /bin/bash to be a bash shell code?

3

I am using Emacs on a LINUX system that uses Portable Batch System (PBS) for controlling the use of resources. The PBS scripts require "#PBS -S /bin/..." as the first line in the script to declare the shell of the script to PBS. When I load the script into Emacs, there is no #!/bin/... to alert Emacs to which shell is being programmed. So, how can I get the shell-script-mode in Emacs to intepret #PBS -S /bin/bash to be a bash shell code?

Stephen Alter

Posted 2013-08-27T19:18:19.400

Reputation: 31

Answers

1

Add this to your .emacs:

(setq auto-mode-interpreter-regexp 
    "#\\(?:!\\|PBS -S \\)[ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)")

That makes Emacs consider #PBS -S as an alternative to the #! prefix.

legoscia

Posted 2013-08-27T19:18:19.400

Reputation: 2 197

0

Add something like the following to the end of the file:

# Local Variables:
# mode: shell-script
# End: 

Of course, there are other ways, such as a distinct naming pattern used for setting the variable auto-mode-alist.

Haider

Posted 2013-08-27T19:18:19.400

Reputation: 1