Skip to content
Advertisement

Why does “/usr/bin/env bash -x” only work in command line?

I am playing with a docker CentOS image, and find executing “/usr/bin/env bash -x” command is OK in terminal:

JavaScript

But after writing this command into a script and execute it, it doesn’t work, and prompts “No such file or directory“:

JavaScript

Is there any difference between two methods?

Advertisement

Answer

The short answer is that you only get one parameter to the interpreter which is specified via the “#!” mechanism. That became “bash -x”.

Usually the limitation is more apparent, e.g., using

JavaScript

would pass “-x -i” as the parameter, and get unexpected results.

Sven Mascheck comments on this in his page on the topic:

most systems deliver all arguments as a single string

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement