@@ -20,10 +20,9 @@ impl Generator for Bash {
2020
2121 let fn_name = bin_name. replace ( '-' , "__" ) ;
2222
23- w ! (
23+ write ! (
2424 buf,
25- format!(
26- "_{name}() {{
25+ "_{name}() {{
2726 local i cur prev opts cmd
2827 COMPREPLY=()
2928 cur=\" ${{COMP_WORDS[COMP_CWORD]}}\"
6665 complete -F _{name} -o bashdefault -o default {name}
6766fi
6867" ,
69- name = bin_name,
70- cmd = fn_name,
71- name_opts = all_options_for_path( cmd, bin_name) ,
72- name_opts_details = option_details_for_path( cmd, bin_name) ,
73- subcmds = all_subcommands( cmd, & fn_name) ,
74- subcmd_details = subcommand_details( cmd)
75- )
76- . as_bytes( )
77- ) ;
68+ name = bin_name,
69+ cmd = fn_name,
70+ name_opts = all_options_for_path( cmd, bin_name) ,
71+ name_opts_details = option_details_for_path( cmd, bin_name) ,
72+ subcmds = all_subcommands( cmd, & fn_name) ,
73+ subcmd_details = subcommand_details( cmd)
74+ ) . expect ( "failed to write completion file" ) ;
7875 }
7976}
8077
@@ -274,22 +271,23 @@ fn all_options_for_path(cmd: &Command, path: &str) -> String {
274271
275272 let mut opts = String :: new ( ) ;
276273 for short in utils:: shorts_and_visible_aliases ( p) {
277- write ! ( & mut opts, "-{short} " ) . unwrap ( ) ;
274+ write ! ( & mut opts, "-{short} " ) . expect ( "writing to String is infallible" ) ;
278275 }
279276 for long in utils:: longs_and_visible_aliases ( p) {
280- write ! ( & mut opts, "--{long} " ) . unwrap ( ) ;
277+ write ! ( & mut opts, "--{long} " ) . expect ( "writing to String is infallible" ) ;
281278 }
282279 for pos in p. get_positionals ( ) {
283280 if let Some ( vals) = utils:: possible_values ( pos) {
284281 for value in vals {
285- write ! ( & mut opts, "{} " , value. get_name( ) ) . unwrap ( ) ;
282+ write ! ( & mut opts, "{} " , value. get_name( ) )
283+ . expect ( "writing to String is infallible" ) ;
286284 }
287285 } else {
288- write ! ( & mut opts, "{pos} " ) . unwrap ( ) ;
286+ write ! ( & mut opts, "{pos} " ) . expect ( "writing to String is infallible" ) ;
289287 }
290288 }
291289 for ( sc, _) in utils:: subcommands ( p) {
292- write ! ( & mut opts, "{sc} " ) . unwrap ( ) ;
290+ write ! ( & mut opts, "{sc} " ) . expect ( "writing to String is infallible" ) ;
293291 }
294292 opts. pop ( ) ;
295293
0 commit comments