DoomHammer / brewstrap

Bootstraps Linuxbrew on machines lacking necessary tools (such as Chromebooks and embedded)
Other
6 stars 0 forks source link

/bin/sh isn't always bash #3

Closed minektur closed 8 years ago

minektur commented 8 years ago

On chromeos, some flavors of debian/ubuntu and others, /bin/sh is actually dash shell, and is only POSIX-ly compatible. There are a few things in brewstrap-0.1.sh that rely on bash features (command line parsing of --fixpaths for instance).

You probably want to explicitly call bash, or change your [ tests to be dash compatible...

I added set -x as 2nd line of script to demonstrate:

chronos@localhost ~ $ ./brewstrap-0.1.sh
+ VERSION=0.1
+ pwd
+ ORIGWD=/usr/local/fred
+ BREWSTRAP_DIR=/usr/local/fred/.linuxbrew/Cellar/brewstrap/0.1
+ [ x == x--fixpaths ]
[: 1: x: unexpected operator
+ before_extraction
...

You can read all about dash vs bash and how to convert here:

https://wiki.ubuntu.com/DashAsBinSh

In this particular instance changing

if [ "x$1" == "x--fixpaths" ]; then

to

if [ "x$1" = "x--fixpaths" ]; then

(e.g. just changing == to =) should do the trick

DoomHammer commented 8 years ago

Funny, as I have been testing it under Busybox's sh which isn't bash either. Thought this would be most conservative of all, but I've been proven wrong. Thanks for the report, @minektur !

DoomHammer commented 8 years ago

Does #4 help in that matter?

minektur commented 8 years ago

it solves the immediate problem yes.