File tree 4 files changed +13
-7
lines changed
clap_complete/src/dynamic/shells
4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ impl crate::dynamic::Completer for Bash {
23
23
let mut upper_name = escaped_name. clone ( ) ;
24
24
upper_name. make_ascii_uppercase ( ) ;
25
25
26
- let completer = shlex:: quote ( completer) ;
26
+ let completer =
27
+ shlex:: try_quote ( completer) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( completer) ) ;
27
28
28
29
let script = r#"
29
30
_clap_complete_NAME() {
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ impl crate::dynamic::Completer for Elvish {
13
13
completer : & str ,
14
14
buf : & mut dyn std:: io:: Write ,
15
15
) -> Result < ( ) , std:: io:: Error > {
16
- let bin = shlex:: quote ( bin) ;
17
- let completer = shlex:: quote ( completer) ;
16
+ let bin = shlex:: try_quote ( bin) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( bin) ) ;
17
+ let completer =
18
+ shlex:: try_quote ( completer) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( completer) ) ;
18
19
19
20
let script = r#"
20
21
set edit:completion:arg-completer[BIN] = { |@words|
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ impl crate::dynamic::Completer for Fish {
13
13
completer : & str ,
14
14
buf : & mut dyn std:: io:: Write ,
15
15
) -> Result < ( ) , std:: io:: Error > {
16
- let bin = shlex:: quote ( bin) ;
17
- let completer = shlex:: quote ( completer) ;
16
+ let bin = shlex:: try_quote ( bin) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( bin) ) ;
17
+ let completer =
18
+ shlex:: try_quote ( completer) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( completer) ) ;
19
+
18
20
writeln ! (
19
21
buf,
20
22
r#"complete -x -c {bin} -a "("'{completer}'" complete --shell fish -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ impl crate::dynamic::Completer for Zsh {
13
13
completer : & str ,
14
14
buf : & mut dyn std:: io:: Write ,
15
15
) -> Result < ( ) , std:: io:: Error > {
16
- let bin = shlex:: quote ( bin) ;
17
- let completer = shlex:: quote ( completer) ;
16
+ let bin = shlex:: try_quote ( bin) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( bin) ) ;
17
+ let completer =
18
+ shlex:: try_quote ( completer) . unwrap_or ( std:: borrow:: Cow :: Borrowed ( completer) ) ;
19
+
18
20
let script = r#"#compdef BIN
19
21
function _clap_dynamic_completer() {
20
22
export _CLAP_COMPLETE_INDEX=$(expr $CURRENT - 1)
You can’t perform that action at this time.
0 commit comments