Skip to content

Commit

Permalink
Drop basename in favor of Bash strings
Browse files Browse the repository at this point in the history
Convert `var=$(basename $file)` to `var="${file##*/}”`, everywhere except themes.
  • Loading branch information
gaelicWizard committed Mar 5, 2022
1 parent 1c780bb commit f98f5ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion completion/available/hub.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ EOF
((c++))
done
if [ -z "$name" ]; then
repo="$(basename "${PWD}")"
repo="${PWD##*/}"
fi
case "$prev" in
-d|-h)
Expand Down
18 changes: 10 additions & 8 deletions completion/available/knife.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ _KAC_get_and_regen_cache() {
_KAC_clean_cache() {
local FILE CMD
# delete all obsolete temp files, could be lingering there for any kind of crash in the caching process
for FILE in "$_KAC_CACHE_TMP_DIR"/*; do
for FILE in "$_KAC_CACHE_TMP_DIR"/*
do
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" || rm -f "$FILE"
done
# refresh really stale caches
find "$_KNIFE_AUTOCOMPLETE_CACHE_DIR" -maxdepth 1 -type f -not -name '.*' \
| while read -r FILE; do
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" && continue
# first let's get the original command
CMD=$(_KAC_get_command_from_cache_name "$(basename "$FILE")")
# then regen the cache
_KAC_get_and_regen_cache "$CMD" > /dev/null
done
| while read -r FILE
do
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" && continue
# first let's get the original command
CMD=$(_KAC_get_command_from_cache_name "${FILE##*/}")
# then regen the cache
_KAC_get_and_regen_cache "$CMD" > /dev/null
done
}

# perform a cache cleaning when loading this file
Expand Down

0 comments on commit f98f5ac

Please sign in to comment.