nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: clap-rs/clap
Pull request #5661 (2024-08-11 00:24:15)

fix(complete): Ensure bash does not sort, we do
<!--
Thanks for helping out!

Please link the appropriate issue from your PR.

If you don't have an issue, we'd recommend starting with one first so the PR can focus on the
implementation (unless its an obvious bug or documentation fix that will have
little conversation).
-->



Patch:
diff --git a/clap_complete/src/dynamic/shells/command.rs b/clap_complete/src/dynamic/shells/command.rs
index e442310e..eae385cc 100644
--- a/clap_complete/src/dynamic/shells/command.rs
+++ b/clap_complete/src/dynamic/shells/command.rs
@@ -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)


Test patch:
diff --git a/clap_complete/tests/snapshots/home/dynamic/exhaustive/bash/.bashrc b/clap_complete/tests/snapshots/home/dynamic/exhaustive/bash/.bashrc
index a1b28384..f1bd2f1f 100644
--- a/clap_complete/tests/snapshots/home/dynamic/exhaustive/bash/.bashrc
+++ b/clap_complete/tests/snapshots/home/dynamic/exhaustive/bash/.bashrc
@@ -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
 
 
diff --git a/clap_complete/tests/snapshots/register_minimal.bash b/clap_complete/tests/snapshots/register_minimal.bash
index 24ae5784..7198bfe1 100644
--- a/clap_complete/tests/snapshots/register_minimal.bash
+++ b/clap_complete/tests/snapshots/register_minimal.bash
@@ -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