Skip to content

Commit

Permalink
zsh,aot: Warn on unexpected output script filename
Browse files Browse the repository at this point in the history
  • Loading branch information
adaszko committed Jan 23, 2024
1 parent 39c7cb2 commit 5e29dcb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::ffi::OsStr;
use std::io::{BufWriter, Write, Read};
use std::path::Path;
use std::process::exit;

use anyhow::Context;
Expand Down Expand Up @@ -421,6 +423,10 @@ fn compile(args: &AotArgs) -> anyhow::Result<()> {

if let Some(path) = &args.zsh_script {
log::debug!("Writing Zsh completion script");
let expected_name = format!("_{}", validated.command);
if path != "-" && Path::new(path).file_name().unwrap_or_default() != OsStr::new(&expected_name) {
eprintln!("Warning: ZSH requires the output script to be named {expected_name:?} for autoloading to work");
}
let script_file = get_file_or_stdout(path)?;
let mut writer = BufWriter::new(script_file);
complgen::aot::zsh::write_completion_script(&mut writer, &validated.command, &dfa)?;
Expand Down

0 comments on commit 5e29dcb

Please sign in to comment.