-
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/helpers: lint, cleanup, & improvements #1934
Merged
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
6 tasks
gaelicWizard
force-pushed
the
helpers
branch
6 times, most recently
from
September 9, 2021 05:52
a40ce04
to
ec21378
Compare
gaelicWizard
force-pushed
the
helpers
branch
10 times, most recently
from
September 17, 2021 20:16
1ed2b5f
to
213c8c7
Compare
gaelicWizard
force-pushed
the
helpers
branch
6 times, most recently
from
September 20, 2021 05:55
05bba7b
to
ec0c36f
Compare
6 tasks
gaelicWizard
force-pushed
the
helpers
branch
4 times, most recently
from
September 23, 2021 20:13
05b0f00
to
71e3afc
Compare
gaelicWizard
force-pushed
the
helpers
branch
from
September 30, 2021 02:57
71e3afc
to
6822177
Compare
gaelicWizard
force-pushed
the
helpers
branch
10 times, most recently
from
January 9, 2022 04:07
dd1287f
to
aeb784f
Compare
6 tasks
- Don't write to disk, just pipe. - Don't loop, just do all functions. Performance of old implementation on my system: ``` real 0m9.996s user 0m5.318s sys 0m9.126s ``` Performance of new implementation on my system: ``` real 0m0.052s user 0m0.069s sys 0m0.025s ```
The weird subshell is weird AF. Just do a normal `if`. Ditto `_binary_exists()`, `_completion_exists()`, and `_is_function()`!
Quote things, SC2268, SC2143, SC2181, SC2162, SC2016, SC2013, &c. Rewrite globbing per `shellcheck`’s SC2013, and alsö s/typeset/local/g. Eliminate `compgen` where possible. Alsö: use the existing utility functions `_bash-it-get-component-type-from-path` and `_bash-it-get-component-name-from-path`, which just use parameter substitution anyway. Why was `sed` here? Alsö, don't add not-existing directories to `$PATH` in `pathmunge()`. Finally, merge PR Bash-it#1865 from NoahGorny...and clean it a bit...
lib/helpers: lint `_bash-it-migrate()` lib/helpers: lint `_disable-thing()` lib/helpers: lint `_enable-thing()` lib/helpers: lint `_help-list-aliases()` lib/helpers: lint `_help-plugins()` lib/helpers: some SC2034 fixes And SC2154 in `_make_reload_alias()` lib/helpers: lint `all_groups()`
My apologies to future `git blame` hunters ♥
- Improve `pushd`/`popd` somewhat - local some parameters - Lose weird Mac-specific alternate shell startup file (Bash loads startup files on Mac the same as it does on any other *nix system.)
Use `_bash-it-component-item-is-enabled()` Fix SC2295
Use curly braces when `$1` is unseparated from words in a string.
Co-authored-by: Kostas Giapis <45879751+tsiflimagas@users.noreply.github.com>
Replace weird non-globs with array and loop, as suggested by `shellcheck`. Alsö, simplify several constructs to eliminate external binaries. Alsö, see mvdan/sh issue 558 lib/helpers: unbound positional parameters
- add some `local` variables, - don't subshell `_typeset_functions`,
Duplicate function of existing `_bash-it-component-item-is-enabled()`.
Quote some parameter uses that don't strictly require it, but since Bash needs so many quotes everywhere else my brain worms feel better when these are quoted too. lib/helpers: simplify some quote escapes
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 see individual commit notes for detailed information if relevant.
Description
This is a partial PR covering only the
lib/helpers
portion of #1917 in support of #1696 and fixes #1978.This PR touches many files due to some scope overlap with
lib/utilities
and due to touching BATS: I needed to add several.keep
files to protect empty folders fromgit
.Closes #1978.
Motivation and Context
My
shellcheck
branch (#1917) got a bit large, so I'm splitting it up. This PR includes only changes tolib/helpers
(and a littlelib/utilities
):_is_function
behave similarly to_command_exists
,_completion_exists
,_binary_exists
, &c.pathmunge
not add not-existing directories to$PATH
_bash-it-get-component-type-from-path()
and...name-from-path()
all_groups()
from 10 seconds to run to less than one tenth of a second.plugin/ruby
as they weren't working on Mac OS X, turns out due to the fact that we set$HOME
to$TMPDIR
in our test suite on Mac, which I only figured out after messing around with BATS quite a bit._bash-it-component-item-is-enabled()
not rely on reading every single file from disk, parsing metadata, then grep and awk.How Has This Been Tested?
The full test suite and
shellcheck
have run on #1917 and this is part of my main branch since september.Types of changes
Checklist:
clean_files.txt
and formatted it usinglint_clean_files.sh
.