user.js icon indicating copy to clipboard operation
user.js copied to clipboard

Make Updater.sh shell agnostic

Open asimovc opened this issue 1 year ago • 7 comments

My distros use busybox ash and the Updater.sh is using bash to work. I think making shell agnostic is better for just works in all systems.

Wha i expect is it just run as normal and i get this instead.

env: can't execute 'bash': No such file or directory

asimovc avatar Jun 17 '24 04:06 asimovc

Not all bash scripts are compatible with Shell: https://www.gnu.org/software/bash/manual/html_node/Shell-Compatibility-Mode.html

Therefore all script file should tested before run other interpreters.

But ash is a shell implementation. Most of OS put /bin/sh to reference to default interpreter (which in your case /bin/ash). So for temporary solution on your local machine you try to change first line:

https://github.com/arkenfox/user.js/blob/master/updater.sh#L1

as:

#!/bin/sh

or

#!/usr/bin/env sh

And run the script directly from your terminal. Then you can tell us the results please :) You will be the first tester :)

yusuf-daglioglu avatar Jul 09 '24 12:07 yusuf-daglioglu

The current scripts uses a lot more bash extensions than supported by busybox ash. You check that with shellcheck 0.10.0+ quit easily: shellcheck -s busybox -S error -e SC3036 *.sh

Compatibility with more shells would only work when using a simpler standard like POSIX shell.

sertonix avatar Jul 09 '24 12:07 sertonix

@yusufdaglioglu when i put #!/usr/bin/env sh i get this

./updater.sh: line 20: syntax error: bad substitution
./updater.sh: line 21: syntax error: bad substitution

asimovc avatar Jul 10 '24 02:07 asimovc

checkbashisms and shellcheck would be useful if anyone is willing to port the script. (former is just a perl script, latter is both cross-platform and has a browser version). currently the script does make use of select which doesn't have any pure sh equivalent, so unfortunately it's not trivial...

MagicalDrizzle avatar Aug 26 '24 10:08 MagicalDrizzle

@MagicalDrizzle Most of the fixes are trivial, I've got it down to five blocks of code that need a bit more thinking, select being one of them but should be simple as it just needs a hand-rolled implementation. There are some convoluted logic, so for the first commit I would just port it as-is as much as possible. I would also need some testers, especially for macOS as I don't have easy access to it.

9ao9ai9ar avatar Oct 16 '24 21:10 9ao9ai9ar

@9ao9ai9ar I would be willing to be a tester for BusyBox. (plus the windows port and dash too for good measure)

MagicalDrizzle avatar Oct 17 '24 03:10 MagicalDrizzle

Now this looks ugly with the dangling commits. Apologies for my inexperience with Git and GitHub and the inconvenience/frustrations the forced-pushes may have caused you.

9ao9ai9ar avatar Feb 24 '25 15:02 9ao9ai9ar