0

This question already has an answer here:

I tried to pass parameters to bash in shebang of executable script:

#! /usr/bin/env bash -ex

false

But I get an error:

/usr/bin/env: ‘bash -ex’: No such file or directory

Should I avoid to use /usr/bin/env in favor of /bin/bash to avoid error, or there is a way to stick with /usr/bin/env?

I am on Ubuntu 16.04.3.

marked as duplicate by Kusalananda bash Jan 29 '18 at 6:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Put set -ex in your script? – muru Jan 29 '18 at 6:56
  • It is not an option. The script intended for standalone using (directly with default environment, when I debug it) and for calling from another script, where set -ex is superfluous. – Orient Jan 29 '18 at 7:04
  • Then you don't need it in the shebang. – muru Jan 29 '18 at 7:05
  • I want to type just ./script, or even script if dirpath in $PATH. Surely I can type bash -ex $( which script ), but it is too wordy. – Orient Jan 29 '18 at 7:19
  • Also related, but the opposite question: unix.stackexchange.com/questions/361794/… – Kusalananda Jan 29 '18 at 7:49

Browse other questions tagged or ask your own question.