Skip to content

Commit

Permalink
fix(complete): Ensure bash does not sort, we do
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 10, 2024
1 parent 3ec980e commit 34c8615
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion clap_complete/src/dynamic/shells/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,11 @@ _clap_complete_NAME() {
compopt -o nospace
fi
}
complete -o nospace -o bashdefault -F _clap_complete_NAME BIN
if [[ \"${{BASH_VERSINFO[0]}}\" -eq 4 && \"${{BASH_VERSINFO[1]}}\" -ge 4 || \"${{BASH_VERSINFO[0]}}\" -gt 4 ]]; then
complete -o nospace -o bashdefault -o nosort -F _clap_complete_NAME BIN
else
complete -o nospace -o bashdefault -F _clap_complete_NAME BIN
fi
"#
.replace("NAME", &escaped_name)
.replace("BIN", bin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ _clap_complete_exhaustive() {
compopt -o nospace
fi
}
complete -o nospace -o bashdefault -F _clap_complete_exhaustive exhaustive
if [[ \"${{BASH_VERSINFO[0]}}\" -eq 4 && \"${{BASH_VERSINFO[1]}}\" -ge 4 || \"${{BASH_VERSINFO[0]}}\" -gt 4 ]]; then
complete -o nospace -o bashdefault -o nosort -F _clap_complete_exhaustive exhaustive
else
complete -o nospace -o bashdefault -F _clap_complete_exhaustive exhaustive
fi


6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/register_minimal.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ _clap_complete_my_app() {
compopt -o nospace
fi
}
complete -o nospace -o bashdefault -F _clap_complete_my_app my-app
if [[ /"${{BASH_VERSINFO[0]}}/" -eq 4 && /"${{BASH_VERSINFO[1]}}/" -ge 4 || /"${{BASH_VERSINFO[0]}}/" -gt 4 ]]; then
complete -o nospace -o bashdefault -o nosort -F _clap_complete_my_app my-app
else
complete -o nospace -o bashdefault -F _clap_complete_my_app my-app
fi

0 comments on commit 34c8615

Please sign in to comment.