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

bash script #537

Closed
bogachenko opened this issue Nov 18, 2018 · 16 comments · Fixed by #541
Closed

bash script #537

bogachenko opened this issue Nov 18, 2018 · 16 comments · Fixed by #541

Comments

@bogachenko
Copy link

bogachenko commented Nov 18, 2018

Hi, I have a question about your script.
https://github.com/ghacksuserjs/ghacks-user.js/blob/master/updater.sh

There are 2 mentions of two packages, wget and curl. These are packages that load something (in our case, user.js).
In this script, they are selected to choose from, because there is an "if" condition. The first package is "curl", but if it is not available (not installed or broken?), Then "wget" comes into play. However, what if there are none. ALL. NOT What then? second "if" is not there?
this is not about debian distributions (for which they are available by default), but about (say) archlinux.
On it, as far as I remember, you need to manually install it (although I could be wrong, I did not use it for a long time).

and so it is possible to supplement the conditions on the verification (presence or absence) of these packages? Is there a guru js here?

I am not a guru in js, and maybe I’ll repeat myself I don’t understand. Explain to me?

I hope I wrote without errors 😢

@Atavic
Copy link

Atavic commented Nov 18, 2018

wget is a common GNU package.

@bogachenko
Copy link
Author

Are you sure?I'm not very

@Atavic
Copy link

Atavic commented Nov 18, 2018

Are you using Arch, right? It's in Extra Repo: https://www.archlinux.org/packages/?name=wget

@bogachenko
Copy link
Author

bogachenko commented Nov 18, 2018

now there is no (win10), But I used it. and I don’t remember that he installed these packages by default

upd
look https://www.archlinux.org/groups/x86_64/base/
archlinux is installed using the main "base" package
but wget or curl is not there

upd2 and even in base-devel there are none (these are just basic build tools (packages). they may not be needed)
https://www.archlinux.org/groups/x86_64/base-devel/

@earthlng
Copy link
Contributor

I agree there's room for improvement. Pull requests are welcome :)

@overdodactyl
Copy link
Contributor

overdodactyl commented Nov 18, 2018

I was just messing with a variant that uses perl to download files instead of wget or curl.

It's using File::Fetch, which appears to be base perl. It's a little slower than wget and curl, but I think macOS and linux should all have perl pre-installed.

It could also just be added as a third-option I guess.

Anyone have any thoughts on that?

pinging @earthlng and @claustromaniac

@claustromaniac
Copy link
Contributor

claustromaniac commented Nov 18, 2018

Sounds like a good idea to me.

It still might be a good plan to add a check for simply aborting when even perl is missing, though. There are a gazillion distros out there and more will spawn on time, we can't possibly know for sure whether they all have/will have one of those or not.

@overdodactyl
Copy link
Contributor

Good point - do you think we should keep the wget and curl options, or just switch to perl entirely?

@claustromaniac
Copy link
Contributor

claustromaniac commented Nov 18, 2018

At just 2-3 lines per additional check I'd just keep them all :) Then again, I'm not too finicky when it comes to etiquette and saving bytes and such... 😅

Edit: readability is not my specialty either...

@earthlng
Copy link
Contributor

just FYI: curl in ArchLinux is required by 241 packages, 1 being pacman ie the archlinux package manager so I'm pretty sure most if not all Archlinux' will have curl installed.
But a check in the script is still a good idea.

do you think we should keep the wget and curl options

I would keep it and just add perl as a last resort because you said it's slower

@overdodactyl
Copy link
Contributor

Sounds good! It looks like @claustromaniac already added a check in #540, so we're good there.

If curl is that widely used, the pearl option probably doesn't add a whole lot, but I can throw it in!

@earthlng
Copy link
Contributor

Feel free to add a perl fallback but I think every system with Firefox installed will almost certainly also have curl or wget. At least so far nobody reported a problem and OP only guessed about Arch not having it.

@bogachenko
Copy link
Author

bogachenko commented Nov 19, 2018

@earthlng

and OP only guessed about Arch not having it

I am (practically) sure on 60 percent.
in base and base-devel they are not.
(I don’t know if you are using Linux, but) archlinux is installed along this guide https://wiki.archlinux.org/index.php/Installation_guide.
and they are not in any group of packages. nobody pulls them

You can check for yourself

@earthlng
Copy link
Contributor

@bogachenko pacman is a base package and curl is a dependency of pacman

@bogachenko
Copy link
Author

@earthlng damn, you're right

@earthlng
Copy link
Contributor

new version of the updater.sh is in the works so I'm closing this

earthlng pushed a commit that referenced this issue Nov 19, 2018
* Uses `perl` as a last resort if `curl` and `wget`  are not available (fixes #537)
* Aborts and notifies user if none of the above are installed 
* Better use of functions
* When version numbers are checked, the contents are immediately saved to a temp dir.  This allows us to skip using wget/curl/perl a second time
* Improved messages for users
* Added various font colors for ease of use and aesthetics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants