Home Forums Kamanja Forums Problems & Solutions "Bad substitution" error in kamanja script on Ubuntu Linux (possibly all Debian

This topic contains 0 replies, has 1 voice, and was last updated by  Archived_User1 1 year, 6 months ago.

  • Author
    Posts
  • #13545 Reply

    Archived_User1
    Participant

    kbill
    16 Feb
    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[0]” 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
    sudo ./test.sh
    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

Reply To: "Bad substitution" error in kamanja script on Ubuntu Linux (possibly all Debian
Your information: