-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
lib/utilities: refactor _bash-it-pluralize-component()
& other improvements
#1999
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gaelicWizard
force-pushed
the
utilities
branch
5 times, most recently
from
December 27, 2021 22:05
f592e64
to
8842ff1
Compare
gaelicWizard
changed the title
Utilities: fixes & improvements
Utilities: refactor Dec 27, 2021
_bash-it-pluralize-component()
& other improvements
gaelicWizard
force-pushed
the
utilities
branch
3 times, most recently
from
December 29, 2021 07:06
8ea16b7
to
a72c04e
Compare
gaelicWizard
force-pushed
the
utilities
branch
3 times, most recently
from
January 2, 2022 01:48
670ddbf
to
de71edc
Compare
@tsiflimagas, want to take a look at this one too? 😆 |
gaelicWizard
force-pushed
the
utilities
branch
from
January 2, 2022 05:54
de71edc
to
f95bf32
Compare
gaelicWizard
changed the title
Utilities: refactor
lib/utilities: refactor Jan 2, 2022
_bash-it-pluralize-component()
& other improvements_bash-it-pluralize-component()
& other improvements
NoahGorny
approved these changes
Jan 3, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can merge this after #2002
gaelicWizard
force-pushed
the
utilities
branch
2 times, most recently
from
January 8, 2022 16:24
268f994
to
ed3bea6
Compare
@NoahGorny, I don't think any of this depends on my BATS branch |
Make `_bash-it-component-item-is-enabled()` operate *without* using `_bash-it-component-help()`...so it's now *much* faster.
Alsö, minor tweak to `_bash-it-array-contains-element()` for clarity. This fixes Bash-it#1978.
Fix up and rename `_bash-it-pluralize-component()` to `_bash-it-component-pluralize()`, and add matching function `_bash-it-component-singularize()`.
Match idiom of `_bash-it-component-singularize()`
Don't use `local -n var` so that we can support v3.2... Note: function names and variable names are different namespaces, so we can have a variable named the same as the function...which makes it really easy to predict default names for results when returning this way.
gaelicWizard
force-pushed
the
utilities
branch
from
January 9, 2022 08:54
d60b035
to
7430a06
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please review commit notes as appropriate.
Description
_bash-it-pluralize-component()
;_bash-it-component-item-is-enabled()
(so it's much faster);_bash-it-component-help()
for long component names;Motivation and Context
Refactoring
_bash-it-pluralize-component()
started by accident while fiddling withbash-it search
and resulted in:_bash-it-component-singularize()
which can be used when logging and other places,printf
's-v
flag to store to a variable, rather than echoing tostdout
to reduce subshells,_bash-it-component-cache-file()
and_bash-it-component-help()
to use the variable,_bash-it-component-cache-file()
to useprintf -v
too.Alsö, misc fixes to
lib/utilities
that came along with the branch and deobfuscation oftests/utilities
.How Has This Been Tested?
These fixes have long been part of my main branch and my
shellcheck
branch(es), and all automated tests pass.Types of changes
Checklist:
clean_files.txt
and formatted it usinglint_clean_files.sh
.