Skip to content

Commit

Permalink
squashed lib/search
Browse files Browse the repository at this point in the history
- 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
```

lib/helpers: fix `_command_exists()`

The weird subshell is weird AF. Just do a normal `if`.

Ditto `_binary_exists()`, `_completion_exists()`, and `_is_function()`!

lib/helpers: first `shellcheck` pass

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: second `shellcheck` pass

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()`

lib/helpers: `shfmt`

My apologies to future `git blame` hunters ♥

lib/helpers: cleanup

- 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.)

lib/helpers: fix `_bash-it-describe()`

Use `_bash-it-component-item-is-enabled()`

Fix SC2295

lib/helpers: be extra careful with word splitting

Use curly braces when `$1` is unseparated from words in a string.

lib/helpers: use `awk` to count lines instead of piping to `wc -l`

Co-authored-by: Kostas Giapis <[email protected]>

lib/helpers: remove weird non-globs

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

lib/helpers: fix profile subcommand tests

lib/helpers: juse use `awk`, insteado of `grep | awk`

lib/helpers: simplify some functions

- add some `local` variables,
- don't subshell `_typeset_functions`,

lib/utilities: autonomize `_bash-it-component-item-is-enabled()`

lib/helpers: delete `_bash-it-determine-component-status-from-path()`

Duplicate function of existing `_bash-it-component-item-is-enabled()`.

lib/helpers: quotes for consistency

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

lib/search: code style cleanup

Couldn't even `shellcheck` until I did a first pass...too much noise! ♥

lib/search: `shellcheck`

SC2076
SC2091
SC2004
SC2086
SC2207

lib/search: fix `_bash-it-flash-term()`

1. `$text_black` isn't a parameter provided by _Bash It_. Typo?
2. `$bold_yellow` is meant for prompt strings and putputs `\[`; ditto `$bold_red`.
3. The color was never returned to normal after.

lib/search: fix usage statement `_bash-it-search()`

SC2154

lib/search: `shfmt`

My apologies to future `git blame` hunters ♥

lib/utilities: fix `_bash-it-component-help()` for long component names

Alsö, minor tweak to `_bash-it-array-contains-element()` for clarity.

This fixes Bash-it#1978.

lib/search: code cleanup

Improve `_bash-it-erase-term()`, `_bash-it-flash-term()`, `_bash-it-rewind()`, `_bash-it-search-result()`, and `_bash-it-search-component()`. Minor tweaks to `_bash-it-is-partial-match()`, and `_bash-it-search()`.
  • Loading branch information
gaelicWizard committed Jan 19, 2022
1 parent 86c1e3c commit 2520df7
Show file tree
Hide file tree
Showing 11 changed files with 1,209 additions and 1,201 deletions.
2 changes: 2 additions & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash

# libraries
lib/helpers.bash
lib/search.bash
lib/utilities.bash

# plugins
Expand Down
Loading

0 comments on commit 2520df7

Please sign in to comment.