-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
WIP - Improvements to bash code w/ test suite #2810
base: github
Are you sure you want to change the base?
Commits on Nov 4, 2023
-
Use /usr/bin/env style shebangs for bash
This style is preferred as it makes it possible to use more modern bash on systems where /bin/bash is ancient. (looking at you, macos)
Configuration menu - View commit details
-
Copy full SHA for fedb1a8 - Browse repository at this point
Copy the full SHA fedb1a8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 81b2c30 - Browse repository at this point
Copy the full SHA 81b2c30View commit details -
`set -u` guards against using unassinged vars but most of this code would break. We'll address this later on a file by file basis, with tests.
Configuration menu - View commit details
-
Copy full SHA for c37f4cc - Browse repository at this point
Copy the full SHA c37f4ccView commit details -
Add a test suite and
make test
supportThe first test is to apply shellcheck linting to the bash code. The following commits will address the linting errors found here.
Configuration menu - View commit details
-
Copy full SHA for 87e9628 - Browse repository at this point
Copy the full SHA 87e9628View commit details -
Configuration menu - View commit details
-
Copy full SHA for 56763f3 - Browse repository at this point
Copy the full SHA 56763f3View commit details -
Alway use
[[ ... ]]
conditionalsThe `[` is just a command with args and expects/ignores the `]` final arg. That means you need to be very concerned about what's inside `[ ... ]`. The `[[ ... ]]` is Bash syntax and everything inside is handled as syntax. That means you don't need to quotes variable expansions. Bash knows what you want and does it properly. Some related changes were made in this context: * [[ $foo ]] same as [[ -n $foo ]] same as [[ $foo != "" ]] * [[ -z $foo ]] same as [[ $foo == "" ]] * Prefer == over = for string equality * Prefer -eq over == for numeric equality * $* means all aregs expanded into 1 string * Words without meta chars are strings in Bash. No need to quote them. Note: the RHS of a == or != op must be quoted if it is a variable expansion, but shellcheck would complain if you didn't quote it. All the files are still shellcheck compliant. Very confident of this commit.
Configuration menu - View commit details
-
Copy full SHA for 324d409 - Browse repository at this point
Copy the full SHA 324d409View commit details -
First attempt at using 'set -u'
(in lein and bump) Added a couple tests but need more rigorous testing to make sure everything works without error.
Configuration menu - View commit details
-
Copy full SHA for a7f2178 - Browse repository at this point
Copy the full SHA a7f2178View commit details -
Remove useless quotes from assignment statements
In Bash `foo=$bar` or `foo=$( bar $baz )` is smart about parsing and doesn't blindly expand vars with spaces or meta chars. Arguments with expansions, on the other hand, need quoting. Preferred to only use double quotes when expansions are present. Else use single quotes.
Configuration menu - View commit details
-
Copy full SHA for 7919907 - Browse repository at this point
Copy the full SHA 7919907View commit details -
Configuration menu - View commit details
-
Copy full SHA for eda4479 - Browse repository at this point
Copy the full SHA eda4479View commit details
Commits on Nov 5, 2023
-
Add handy msg, err, and die functions
Makes code cleaner and easier to read. Makes it obvious when things are going to stdout or stderr. Note: `printf` repeats its pattern until all args are consumed, so the `msg` function will print a line for each arg.
Configuration menu - View commit details
-
Copy full SHA for 004581f - Browse repository at this point
Copy the full SHA 004581fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 82c3ce1 - Browse repository at this point
Copy the full SHA 82c3ce1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5b20489 - Browse repository at this point
Copy the full SHA 5b20489View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d4b676 - Browse repository at this point
Copy the full SHA 1d4b676View commit details -
Change function_names to function-names
Unlike vars, functions in bash can contain most of the chars found in file names, which makes sense as a command can either be a function or a PATH command. A Lisper should like it.
Configuration menu - View commit details
-
Copy full SHA for 8841944 - Browse repository at this point
Copy the full SHA 8841944View commit details -
Note: you can end a line with && || or | and it will continue without using \.
Configuration menu - View commit details
-
Copy full SHA for 9a96fae - Browse repository at this point
Copy the full SHA 9a96faeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4550cb0 - Browse repository at this point
Copy the full SHA 4550cb0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2b599dc - Browse repository at this point
Copy the full SHA 2b599dcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 622ce2d - Browse repository at this point
Copy the full SHA 622ce2dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 139cb68 - Browse repository at this point
Copy the full SHA 139cb68View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6a804ff - Browse repository at this point
Copy the full SHA 6a804ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 044dbf7 - Browse repository at this point
Copy the full SHA 044dbf7View commit details -
$(dirname "$SCRIPT"$) makes not sense to me. Surprised it's not a bash syntax error though
Configuration menu - View commit details
-
Copy full SHA for f6f0c58 - Browse repository at this point
Copy the full SHA f6f0c58View commit details -
Configuration menu - View commit details
-
Copy full SHA for 906d616 - Browse repository at this point
Copy the full SHA 906d616View commit details