mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Forbid --output=file without a path separator
This commit is contained in:
1 parent
ecee9df575
commit
efdf735723
2 files changed
+9
-1
No files matched your search
@@ -49,4 +49,6 @@ pub enum OptionsError<'a> {
|
||||
EmptyShell,
|
||||
#[error("Failed to parse '--shell <command>' expression as command line: {0}")]
|
||||
ShellParseError(shell_words::ParseError),
|
||||
#[error("Unknown output policy '{0}'. Use ./{0} to output to a file named {0}.")]
|
||||
UnknownOutputPolicy(String),
|
||||
}
|
||||
+7
-1
@@ -275,7 +275,13 @@ impl Options {
|
||||
"null" => CommandOutputPolicy::Discard,
|
||||
"pipe" => CommandOutputPolicy::Pipe,
|
||||
"inherit" => CommandOutputPolicy::Forward,
|
||||
path => CommandOutputPolicy::File(path.into()),
|
||||
arg => {
|
||||
let path = PathBuf::from(arg);
|
||||
if path.components().count() <= 1 {
|
||||
return Err(OptionsError::UnknownOutputPolicy(arg.to_string()));
|
||||
}
|
||||
CommandOutputPolicy::File(path)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CommandOutputPolicy::Discard
|
||||
|
||||
Reference in new issue
Block a user