nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: clap-rs/clap
Pull request #4896 (2023-05-09 19:02:23)

completion: Respect `ValueHint::Other` in Bash
The bash completion currently generates `compgen -f` by default, or `compgen -W ...` for exhaustive values. This checks for `ValueHint::Other` so that file completion can at least be disabled where inappropriate


Patch:
diff --git a/clap_complete/src/shells/bash.rs b/clap_complete/src/shells/bash.rs
index 139e2fc7..60e6b346 100644
--- a/clap_complete/src/shells/bash.rs
+++ b/clap_complete/src/shells/bash.rs
@@ -206,6 +206,8 @@ fn vals_for(o: &Arg) -> String {
                 .collect::<Vec<_>>()
                 .join(" ")
         )
+    } else if o.get_value_hint() == ValueHint::Other {
+        String::from("\"${cur}\"")
     } else {
         String::from("$(compgen -f \"${cur}\")")
     }


Test patch:
diff --git a/clap_complete/tests/snapshots/value_hint.bash b/clap_complete/tests/snapshots/value_hint.bash
index f92d4021..e0a39cb8 100644
--- a/clap_complete/tests/snapshots/value_hint.bash
+++ b/clap_complete/tests/snapshots/value_hint.bash
@@ -34,7 +34,7 @@ _my-app() {
                     return 0
                     ;;
                 --other)
-                    COMPREPLY=($(compgen -f "${cur}"))
+                    COMPREPLY=("${cur}")
                     return 0
                     ;;
                 --path)