-
Notifications
You must be signed in to change notification settings - Fork 528
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
Rewrite into more POSIX-compliant, portable, robust, composable and readable shell scripts #1908
base: master
Are you sure you want to change the base?
Conversation
prefCleaner works fine for me, however updater doesn't seem to be able to append overrides. |
Seems to be just a broken check? This fixes it and updater seems to work fine now. |
Error in both scripts - you were checking for the literal file named // from
SCRIPT_FILE=$(preadlink "$0") && [ -f SCRIPT_FILE ] || exit 1
// to
SCRIPT_FILE=$(preadlink "$0") && [ -f $SCRIPT_FILE ] || exit 1 and for your missing /bin/sh question - no it doesn't seem to work. |
@9ao9ai9ar Thoughts on using |
The POSIX way to do it is to write a program to overwrite the shebang with the path of |
Hey @9ao9ai9ar @MagicalDrizzle I've noticed that progress on this PR is slowing down, so I'm willing to create a checklist of things to ensure that the script is working properly, and then make a GitHub workflow to test the script on different platforms. Here are some things to be checked:
This will tick the GitHub available runners off the list of things that testers have to check manually. Manual tester can then copy the workflow to test locally. What do you think? An alternative would be splitting this PR into smaller PRs. |
The rewrite focuses on the following five areas of interest: 1. Portability. The scripts should be useable across a number of Unix operating systems and shells; goes hand in hand with POSIX- compliance. 2. Robustness. Fail early; borrow from more battle-tested open source code; pass all valid ShellCheck checks. 3. Composability. Put everything inside functions; make the scripts dot source friendly. 4. Consistency. Abstract away terminal color codes with tput; uniform diagnostic messages and standardized use of status codes and redirections. 5. Readability. Extensive comments and descriptive names; use here- docs to ease writing multiline messages. Known behavioral changes: 1. Changed the way the options are parsed and acted on. For example, when both the -p and -l options of updater.sh are specified, -l will be ignored. The old behavior would depend on the order of the options passed, where the last one wins, and the profile path passed as the argument to -p couldn't be named 'list' or it would be treated as if the option -l was specified. 2. All temporary files are created using mktemp, so users won't find them in the working directory anymore should an error occur and they were not removed as a result of that.
@9ao9ai9ar prefsCleaner works, updater only partly - works only if there's already an user.js file. It won't download a new user.js if doesn't exist, then will try to backup the nonexistent user.js file which fails.
|
Now runnable on BSDs, Oracle Solaris 11 and Haiku.
This commit brings many bugfixes after more thorough testing across all targeted platforms (except macOS) and shells. Some of the compound commands in the POSIX shell language, e.g. the while and for loops, have been restructured to allow for more error conditions to be caught. Variable names are reused more often to avoid needlessly littering the shell environment, as they are not scoped locally to the functions, and to reduce the chance of a name collision with variables that are marked readonly for whatever reason.
The starting environment restoration has been improved for a better dot sourcing experience. Renamed status to status_ as the former is a readonly variable in zsh. The scripts can now also be run in XPG4 sh, pdksh, posh and osh. Replaced buggy rreadlink with readlinkf by ShellSpec's author. Minimized the number of variables defined and shell options changed.
Closes #1855 and fixes #1810; duplicate of #1446; duplicate of #1828 and many more. This is not the first POSIX solution to have ever been requested or presented, though certainly the most comprehensive one yet.
The rewrite is complete, though I've only done very rudimentary testing on it, so it should still be treated as beta software at best. Regrettably, the robustness goal hasn't truly been realized, so it would need to be addressed in a separate pull request. I'd also like to point out that alternatives like the one in #1696 exist and are worth considering.
Target Platforms for Modern Desktop Versions of Firefox
Based on the supported build hosts and targets of Firefox.
Tier-1
Windows(WSL, Cygwin, MSYS2, etc.) - Not targeted.Tier-2
psmisc
orlsof
package forprefsCleaner.sh
to work.Tier-3
Non-Tiered
POSIX Compliant Shells
/bin/sh
) - Not tested./bin/sh
and user shell)/bin/sh
)/bin/sh
and user shell)/bin/sh
and user shell)/bin/sh
and user shell)emulate sh
before sourcing.sh
)hush- Not targeted for the time being due to missing crucial features:command -p
and thenoglob
shell option.gash- Not targeted for the time being due to missing crucial feature:command -p
.mrsh- Not targeted for the time being due to many deficiencies, e.g. Function output cannot be redirected emersion/mrsh#196 and command builtin without arguments crashes emersion/mrsh#204.