GoXLR-on-Linux / goxlr-on-linux

Documentation and scripts to make the GoXLR and GoXLR Mini useful on Linux.
142 stars 8 forks source link

install.sh error #12

Closed VirtualJunky closed 3 years ago

VirtualJunky commented 3 years ago

New to Linux so maybe I did something wrong here, but I was getting this error for line 14 and 23 "[[: not found" and after a Google found that I needed to change the first line from "#!/bin/sh" to "#!/bin/bash". Would PR it but as said, brand spankin new to Linux here so maybe I'm in the wrong, but figured I would mention it.

Thanks for the awesome work on this so far, been the only thing holding me back switching or at least trying Linux!

cmoro-deusto commented 3 years ago

Thanks @VirtualJunky I had the same problem. Also thanks a lot to @T-Grave for this!

lm41 commented 3 years ago

How did you execute the script? I've only executed it with sh install.sh. I didn't checked ./install.sh. I did sh install.sh because not everyone has bash as its default shell. If I am wrong, I can change this line. @T-Grave what do you say?

VirtualJunky commented 3 years ago

@lm41 I used chmod +x install.sh because it gave me a no access error otherwise, then simply install.sh and it ran until reboot. I'm using Pop!_OS if that helps any, as said brand new to Linux so unfamiliar with what shell I have, but it would be the same on Ubuntu I believe. Heck, not even sure the difference between sh or bash is quite yet. :)

lm41 commented 3 years ago

Can you try to execute the original script via sh install.sh?

lm41 commented 3 years ago

@VirtualJunky You can type ps -p $$ to get the current shell.

VirtualJunky commented 3 years ago

@lm41 Here's using sh install.sh: https://i.gyazo.com/d61162744ecd1cb2e044e16e2ea0c470.png Also tried bash install.sh: https://i.gyazo.com/769a1a22811ce0b37c3e31e1859c3f01.png

Both tests on a completely fresh version of Pop!_OS, haven't touched a single setting or installed anything. Didn't see the other comment until I was already swapped back to my main OS.

lm41 commented 3 years ago

@VirtualJunky but the bash install.sh did work?

cmoro-deusto commented 3 years ago

The install.sh script contains "bashisms", making it dependent on bash to execute it.

The error @VirtualJunky and myself run into is due to the shebang on the first line: it's interpreted as a directive, making the script actually being executed with the shell interpreted defined in the shebang, if the script is launched "naked" from the comandline (ie ./install.sh).

It works using bash ./install.sh because in that case, the shebang is ignored and the script is directly executed by bash.

To fix this, I see two options:

@lm41 if you prefer the first option, this utility can help locating all the bashism in the script checkbashisms.

IMHO, it would be easy to eliminate the bashisms and hence the need to have bash installed.

Hope this helps.

cmoro-deusto commented 3 years ago

I have checked the scripts against checkbashisms. configure_goxlr.sh and configure_goxlr_mini.sh are OK. install.sh has 4 "issues" to fix, but all 4 are the same (the format of the if condition):

checkbashisms install.sh

possible bashism in install.sh line 14 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ ! -z $APT_GET_CMD ]]; then
possible bashism in install.sh line 17 (alternative test command ([[ foo ]] should be [ foo ])):
    if [[ "$1" = "MINI" ]]; then
possible bashism in install.sh line 23 (alternative test command ([[ foo ]] should be [ foo ])):
elif [[ ! -z $PACMAN_CMD ]]; then
possible bashism in install.sh line 26 (alternative test command ([[ foo ]] should be [ foo ])):
    if [[ "$1" = "MINI" ]]; then
lm41 commented 3 years ago

Ok, I fix this

lm41 commented 3 years ago

In #16 these issues should be resolved.