Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

set: -g: invalid option #4035

Closed
krainboltgreene opened this issue Mar 26, 2017 · 6 comments
Closed

set: -g: invalid option #4035

krainboltgreene opened this issue Mar 26, 2017 · 6 comments

Comments

@krainboltgreene
Copy link

While attempting to share my docker development environment with a friend we ran into a rather strange issue. I'm running zsh and she's running fish. All scripts I've written work on my machine, but as soon as she tries to use ones with the eval "$(docker-machine env lacqueristas)" line things fall apart:

=== Building the container(s) ===
bin/build: line 4: set: -g: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
bin/build: line 5: set: -g: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
bin/build: line 6: set: -g: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
bin/build: line 7: set: -g: invalid option
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

We investigated and found it started here, with the eval line in this file:

#!/usr/bin/env bash

echo "=== Building the container(s) ===" &&
eval "$(docker-machine env lacqueristas)" &&
docker-compose build $1

When we made the script fish compatible (&& -> ; and for example) it worked fine.

Finally she tried to push the default shell and it worked! Here's what it looked like:

#!/usr/bin/env bash

echo "=== Building the container(s) ===" &&
eval "$(docker-machine env lacqueristas --shell default)" &&
docker-compose build $1

Why does this happen and how can we really fix it?

@nathanleclaire
Copy link
Contributor

I'm a bit confused by the behavior. #!/usr/bin/env bash in the script should indicate to use bash to interpret it and the eval line should work more or less the same on different computers. You're invoking these scripts using something like ./script.sh right?

@nathanleclaire
Copy link
Contributor

You might want to check that bash on her machine is actually bash and not fish (though that'd be quite odd, I've seen stranger things)

@krainboltgreene
Copy link
Author

@nathanleclaire The weird thing is that even if we run this script inside a bash shell (aka typing bash from inside fish, seeing the bash prompt, and running bin/build) we still get the error.

I believe it to be somewhere in the sector of eval and maybe the env thing.

@krainboltgreene
Copy link
Author

Oh we also tried #!/usr/bin/env bash and #!/usr/bin/env sh and #!/bin/bash

@matthewayers
Copy link

matthewayers commented Apr 5, 2017

fwiw, I'm seeing the same thing on OS X sierra running from "bash --login" shell (w/ fish as the default)

ok - so, somewhere, in the depths of the OS, the $SHELL var is still returning fish (even if you're in a bash login shell)

so try updating your script from
eval "$(docker-machine env lacqueristas --shell default)"

to

eval "$(docker-machine env lacqueristas --shell bash)"

the equiv worked for me

@nathanleclaire
Copy link
Contributor

Ah, yeah, I've seen that before @matthewayers - good callout, that is most likely the issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants