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

updater.sh error #325

Closed
Thorin-Oakenpants opened this Issue Dec 29, 2017 · 22 comments

Comments

Projects
None yet
7 participants
@Thorin-Oakenpants
Copy link
Member

commented Dec 29, 2017

https://www.ghacks.net/2017/12/29/automation-comes-to-the-ghacks-user-js-configuration-for-firefox/#comment-4325323

when runing the updater on Linux, I have this :

bash updater.sh
updater.sh: line 7: syntax error near unexpected token `newline'
updater.sh: line 7: `'
@claustromaniac

This comment has been minimized.

Copy link
Member

commented Dec 29, 2017

I don't know much about bash, but I would try something like this:

ghacksjs='https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js';

Even though it shouldn't be necessary in that context. The raw already has LF line breaks, by the way. Could it be that it has something to do with .gitattributes? Maybe it needs to explicitly convert bash file line breaks to LF, similar to what happened with the batch scripts?

@overdodactyl

This comment has been minimized.

Copy link
Collaborator

commented Dec 30, 2017

Can't reproduce here on a mac...I'll do some digging on the error message and see if I can come up with anything

@earthlng

This comment has been minimized.

Copy link
Member

commented Dec 30, 2017

I've added .sh to gitattributes: dd29583 - maybe that will fix it

@arnauldb

This comment has been minimized.

Copy link

commented Dec 31, 2017

Thank you @Earthing

I still have the same error:
screenshot https://imgur.com/jVdqABj

bash updater.sh
updater.sh: line 7: syntax error near unexpected token newline' updater.sh: line 7: '

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Dec 31, 2017

I downloaded the file .. well TBH, I opened the file on the web and chose the RAW view and copypasta'd it into a new file .. its all mixed up for me (note: the first code that ends in CRLF is line 7)

mixed

@arnauldb - do you have Notepad++ at all? You can go View>Show Symbol>Show End of Line to see what EOLs you have

You can also go Edit>EOL Conversion>Unix (LF) to fix all the endings to LF, and save the file

Can you try that please? :)

Edit: note: I downloaded the repo zip file and the updater.sh in there is all LF

@claustromaniac

This comment has been minimized.

Copy link
Member

commented Dec 31, 2017

Yeah, it seems it could be what happened with the batch scripts. I'm getting LF line breaks in both the raw and the zipped file, but still, for the batch files merely modifying gitattributes wasn't enough to get GitHub to always use the proper line endings in the raws. For it to work, earthing had to re-upload the file with the right line endings in addition. Maybe the same is necessary now.

@arnauldb

This comment has been minimized.

Copy link

commented Dec 31, 2017

@Thorin-Oakenpants

It just worked, don't know what happened...
selection_001_31_17 21 05

Thank you.

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2018

@arnauldb awesome. I'l leave this open for earthlng to look at the RAW version

@kerframil

This comment has been minimized.

Copy link

commented Jan 1, 2018

The error that arnauldb originally reported at ghacks.net was not symptomatic of carriage returns being present in the content of an otherwise valid shell script. Indeed, I had guessed that it might be an issue with mangled content and the shell processing a redirection operator. Having read his post here, it's clear that he downloaded and attempted to execute an HTML document instead of the raw script content (whose line endings were - and still are - correct).

@Thorin-Oakenpants Pasting content into Notepad++ isn't a valid test because Notepad++ will coerce the line endings into whichever format is in effect for the document window (CRLF by default). Downloading https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh, then opening it with Notepad++ as a separate step would be OK.

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2018

@kerframil Thanks for your expertise. I saw that (HTML reference) in his linked screenshot and wondered about it for second or two, but my lack of knowledge fear prevented me from making a fool of myself :)

Notepad++ will coerce the line endings into whichever format is in effect for the document window (CRLF by default).

I knew it wasn't a totally valid test, but the fact that it had mixed line endings puzzled me - if I can get that, so could others. For ref, I am on Windows, I created a new txt file (right click, new text document), renamed it including ext name, dragged it into Notepad++, and pasted FF browser window contents (raw) into it.

@arnauldb - how did you create/get the updater.sh file the first time round?

@kerframil

This comment has been minimized.

Copy link

commented Jan 1, 2018

No worries, Thorin. For the record, if you use File > Save Page As from FF - selecting All Files as the type - then open the file in Notepad++, the reported line ending format can be trusted. However, you may find it more convenient to paste the URL into the file open dialog of Notepad++.

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2018

^^ true that. Except 99% of my portable apps have no internet access via my firewall :) gonna need MOAR tinfoil xD .. nah, I trust Notepad++, I can let him thru

@claustromaniac

This comment has been minimized.

Copy link
Member

commented Jan 1, 2018

but my lack of knowledge fear prevented me from making a fool of myself :)

If it makes you feel any better, I missed it completely.

I now started wondering how could that have happened, I mean, how could he get an HTML document in the first place? So I checked the link on the article, which merely points to the wiki, and then I discovered that the download link on section 3.3 is wrong:

https://github.com/ghacksuserjs/ghacks-user.js/blob/master/updater.sh

Fixing that will - hopefully - prevent this from happening again.

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2018

what is the link meant to be?

@arnauldb

This comment has been minimized.

Copy link

commented Jan 1, 2018

@kerframil & @claustromaniac

I now started wondering how could that have happened, I mean, how could he get an HTML document in the first place?

yes, sorry for that, I should have checked the content of the "updater.sh" file I ran the first time...

@claustromaniac

This comment has been minimized.

Copy link
Member

commented Jan 1, 2018

what is the link meant to be?

I mean where it says ...

Download the updater.sh script and save it in your profile folder.

the link should be one for the raw version, either...
https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh
or...
https://github.com/ghacksuserjs/ghacks-user.js/raw/master/updater.sh

Otherwise people can end up downloading an HTML document or, if they just follow the link, they have to figure out by themselves that they need to get the raw version.

@arnauldb Don't sweat it, man :) and thanks for letting us know that you couldn't get the script to work.

@Atavic

This comment has been minimized.

Copy link

commented Jan 1, 2018

The best way is to provide it from a specific repository or as a gist, where there's a download button to avoid any of the errors mentioned above. Then the repo could be listed here.

@claustromaniac

This comment has been minimized.

Copy link
Member

commented Jan 1, 2018

@Atavic I see a downside to using gists, and it is that they would need to be manually updated every time that we want to make changes to the scripts in the repository. Also, they can only be edited by the one person who makes them, right?

Secondary repositories sound like a better alternative, I guess. But still, if it were up to me I think I would simply change that part of the wiki to something like this:

Download the updater.sh (right click > save link as...)

@Atavic

This comment has been minimized.

Copy link

commented Jan 1, 2018

👍 Yes.

@kerframil

This comment has been minimized.

Copy link

commented Jan 1, 2018

I recommend that the would-be user is instructed to either:

a) mark the script as executable with chmod +x before executing directly
b) specifically run the script by providing it as an argument to bash (as arnauldb did)

Otherwise, don't be surprised if someone eventually does something along these lines ...

$ curl -O https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh
$ sh updater.sh

Cue a slew of errors because /bin/sh is not necessarily provided by bash and is thus limited to the features defined in the POSIX specification for the Shell Command Language. In short, sh is not bash.

I recommend (a). In that case, the user would need to either place the script in a directory referenced by PATH, such as /usr/local/bin, or qualify the path when executing it. For example: ./updater.sh

EDIT: Related: http://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful.

@Thorin-Oakenpants

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2018

I changed the link to point to the raw version and @kerframil et al, thanks. [edit] We could enhance the Linux/Mac instructions - just awaiting earthlng's input

@arnauldb Special thanks for bring up the problem(s) buddy 💋

@earthlng

This comment has been minimized.

Copy link
Member

commented Jan 5, 2018

The only problem here was that the link didn't point to the raw file and someone downloaded the html document and tried to run that. I believe Linux users know how to make a script executable.
Placing the script in one of the default PATHs won't work because it needs to be in the FF profile folder.

Thorin-Oakenpants added a commit that referenced this issue Jan 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.