Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sh: 74: [: UG}: unexpected operator #28

Open
gauntface opened this issue Feb 13, 2017 · 13 comments
Open

sh: 74: [: UG}: unexpected operator #28

gauntface opened this issue Feb 13, 2017 · 13 comments

Comments

@gauntface
Copy link

When running this with wget command on Raspbian I get the following errors:

sh: 74: [: UG}: unexpected operator
sh: 77: [: UG}: unexpected operator
sh: 88: syntax error: Missing '}'
@glenpike
Copy link
Owner

Maybe retry with

wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/master/npm-g-nosudo.sh | bash

?

@sinhix
Copy link

sinhix commented Mar 28, 2017

With the latter script on bash:

bash: line 142: syntax error near unexpected token `)'
bash: line 142: `    [Yy]* ) fix_env;;'

@maikokuppe
Copy link

Got exactly the same errors in both cases on Ubuntu 16.04

glenpike pushed a commit that referenced this issue May 8, 2017
Ubuntu 16.10 doesn't like the spaces.
@glenpike
Copy link
Owner

glenpike commented May 8, 2017

@maikokuppe - can you please try running the script as below (I've done a Pull Request with a possible fix)

wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh | bash

@gauntface
Copy link
Author

Just tried the PR with possible fix, get the following error:

bash: line 142: syntax error near unexpected token `)'
bash: line 142: `    [Yy]*) fix_env;;'

@joelclimbsthings
Copy link

I got exactly the results as the others with the listed scripts. I'm using Xubuntu 16.04.

@raghav-kukreti
Copy link

Getting the same error right now.
Ubuntu 16.04

glenpike pushed a commit that referenced this issue Jul 30, 2017
case/esac is a PITA - use longwinded if/elif/else ladder.

Another possible fix for #28 - portability of statements.
As we're testing for empty strings, can use "$var"

If users specifies an install dir, assume that's equal to
.npm-packages.  We were assuming it was parent, but that's wrong.
@glenpike
Copy link
Owner

Okay, I've tried fixing this problem again on the branch, please try the following:

wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh | bash

or download the file from the branch and run manually - https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh

If you have problems, please tell me what shell you are running with the following:

which sh | xargs ls -al

@a2nt
Copy link

a2nt commented Jan 31, 2018

@glenpike
I have tried:

wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh | bash

--2018-01-31 18:22:05--  https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3706 (3.6K) [text/plain]
Saving to: ‘STDOUT’

-                                                 100%[===========================================================================================================>]   3.62K  --.-KB/s    in 0s      

2018-01-31 18:22:06 (37.6 MB/s) - written to stdout [3706/3706]




Invalid choice

You may need to add the following to your ~/.bashrc / .zshrc file(s)


export NPM_PACKAGES="/home/tony/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"


bash: line 146: syntax error near unexpected token `elif'
bash: line 146: `elif [ $yn = "Y"  ]; then'

Here's shell info u have requested:

which sh | xargs ls -al
lrwxrwxrwx 1 root root 7 Jan 24 09:33 /usr/bin/sh -> /bin/sh

And linux info:

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.0 (stretch)
Release:        9.0
Codename:       stretch

uname -r
4.14.0-3-amd64

@glenpike
Copy link
Owner

Hi, @a2nt

Okay - it looks like piping the wget output to bash causes issues with the elif statement.
If you download 'manually' change permissions and execute it, what happens?

wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/b28-case-esac/npm-g-nosudo.sh >npm-g-nosudo.sh 

Then

chmod 755 npm-g-nosudo.sh

Then

./npm-g-nosudo.sh

(I've just tried this in a brand new vagrant machine on Ubuntu 16.04 using the shell and it seems to behave correctly)

@glenpike
Copy link
Owner

If that's not behaving, do you have bash installed on Debian - I'm guessing I could change the shebang so it has to run under bash, but that might exclude people - I've tried making it compliant as possible, but maybe doing something wrong there.

@gauntface
Copy link
Author

I just tried this on a Pi and seems to be working as far as I can tell so thank you so much for the continued work and support on this.

Note: This is running using wget.

@glenpike
Copy link
Owner

glenpike commented Feb 4, 2019

Thanks @gauntface - is that using master branch or the PR one?

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

No branches or pull requests

7 participants