npm-g_nosudo icon indicating copy to clipboard operation
npm-g_nosudo copied to clipboard

sh: 74: [: UG}: unexpected operator

Open gauntface opened this issue 8 years ago • 13 comments

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 '}'

gauntface avatar Feb 13 '17 04:02 gauntface

Maybe retry with

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

?

glenpike avatar Feb 13 '17 21:02 glenpike

With the latter script on bash:

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

sinhix avatar Mar 28 '17 12:03 sinhix

Got exactly the same errors in both cases on Ubuntu 16.04

maikokuppe avatar May 08 '17 08:05 maikokuppe

@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

glenpike avatar May 08 '17 19:05 glenpike

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;;'

gauntface avatar May 29 '17 17:05 gauntface

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

joelclimbsthings avatar Jun 04 '17 00:06 joelclimbsthings

Getting the same error right now. Ubuntu 16.04

raghav-kukreti avatar Jul 29 '17 13:07 raghav-kukreti

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

glenpike avatar Jul 30 '17 23:07 glenpike

@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

a2nt avatar Jan 31 '18 11:01 a2nt

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 avatar Feb 25 '18 23:02 glenpike

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.

glenpike avatar Feb 25 '18 23:02 glenpike

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.

gauntface avatar Feb 03 '19 01:02 gauntface

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

glenpike avatar Feb 04 '19 21:02 glenpike