March 19, 2016 at 2:01 am #13517
There is a problem when running on Ubuntu (possibly under any Debian type Linux).
The error is in $KAMANJA_HOME/bin/kamanja.
That script has a copyright header before the line “#!/usr/bin/env bash”
but in order to be executed, that line is required to be the first line in the script file.
When the file is modified to have that line as the first line, then it works correctly.
The problem is that on Ubuntu, if that line is not first, then the script is executed with the Bourne shell (sh) instead of the Basj shell (bash).
On Ubunutu (and possibly all Debian type systems), the Bourne shell on Ubuntu is a link to the “dash” shell, which does not support the “BASH_SOURCE” construct,
(I found this out on Stack Overflow while debugging.)
This was using Kamanja 1.3.1 on Ubuntu 14.04 LTS with all the latest updates.
This can be demonstrated by creating a script that has one line: the ps command.
Then execute the script on Ubuntu using
The resulting output shows the Bourne shell (sh), not the Bash shell.
bill@bill-HP-255-G2-Notebook-PC:~$ sudo ./test.sh
[sudo] password for bill:
PID TTY TIME CMD
25116 pts/8 00:00:00 sudo
25117 pts/8 00:00:00 sh ********** this shows that the Bourne shell is being used, not Bash ****************
25118 pts/8 00:00:00 ps
March 19, 2016 at 2:02 am #13518
What’s happening is that your shell is “sh” because you have sued. Linux defaults to running the script with whatever shell you are using and defaults to “sh” for root. The ps output shows that you have su’ed. It slipped by because the testers here all use Bash for root. You are right, however, that copyright notice needs to go and I am filing a bug report on it. We need to explicitly invoke bash in that script.
March 19, 2016 at 2:02 am #13519
Thanks for the kind reply, Donald!
Of course, you could also just put the invocation of bash as the first line, and leave the copyright below that.
I’ve abandoned Ubuntu for now because I don’t know if this situation exists in other Kamanja scripts. So no I am using CentOS 7
March 19, 2016 at 2:03 am #13520