Skip to content

Commit

Permalink
style(bash-v2): remove trailing newline with parameter expansion
Browse files Browse the repository at this point in the history
Reads cleaner, and saves a subshell compared to the previous approach.
  • Loading branch information
scop committed May 17, 2022
1 parent 884a0f6 commit 960ed90
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions bash_completionsV2.go
Expand Up @@ -127,9 +127,8 @@ __%[1]s_process_completion_results() {
elif (((directive & shellCompDirectiveFilterDirs) != 0)); then
# File completion for directories only
# Use printf to strip any trailing newline
local subdir
subdir=$(printf "%%s" "${out}")
subdir=${out%%$'\n'}
if [[ -n $subdir ]]; then
__%[1]s_debug "Listing directories in $subdir"
pushd "$subdir" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
Expand Down

0 comments on commit 960ed90

Please sign in to comment.