Reputation: 31
We will perform a migration from unix to Linux. the typeset -L only works with ksh
I created the following file:
#!/bin/ksh -u
echo $SHELL
typeset -L21 RUN_LOGL="LOG_FILE "
Normally the shebang should indicate the correct interpreter (ksh). But when I call the script in a bash way:
$ . test.ksh
The output is:
/bin/bash
-bash: typeset: -L: invalid option
typeset: usage: typeset [-aAfFilrtux] [-p] name[=value] ...
the script is interpreter in bash way , and typeset -L is not accepted. whereas if I simply call
$test.ksh
it runs fine.
Is the way we call the script (bash way or ksh way) important enough to ignore the shebang ?
Thank you in advance.
Upvotes: 2
Views: 3007
Reputation: 798744
. test.ksh
Does not execute the script. It is sourcing the script.
Sourcing a script always ignores the shebang. The shebang is only used when the script is executed like:
chmod +x test.ksh
./test.ksh
Upvotes: 9
Reputation: 16041
The shebang is only used if the interpreter was not defined previously, e.g.:
sh myScript.sh
will always invoke your sh
, and ignores the shebang.
Upvotes: 0