diff --git a/CHANGELOG.md b/CHANGELOG.md index 459557c6..540b4cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### yabridgectl + +- Resolve relative paths when adding plugin directories or when changing + settings. + ## [1.6.0] - 2020-09-17 ### Added diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs index 840fc4a0..0496e568 100644 --- a/tools/yabridgectl/src/main.rs +++ b/tools/yabridgectl/src/main.rs @@ -121,13 +121,24 @@ fn main() -> Result<()> { ) .get_matches(); + // We're calling canonicalize when adding and setting paths since relative paths would cause + // some weird behaviour. There's no built-in way to make relative paths absoltue without + // resolving symlinks, but I don't think this will cause any issues. + // + // https://github.com/rust-lang/rust/issues/59117 match matches.subcommand() { - ("add", Some(options)) => { - actions::add_directory(&mut config, options.value_of_t_or_exit("path")) - } - ("rm", Some(options)) => { - actions::remove_directory(&mut config, &options.value_of_t_or_exit::("path")) - } + ("add", Some(options)) => actions::add_directory( + &mut config, + options + .value_of_t_or_exit::("path") + .canonicalize()?, + ), + ("rm", Some(options)) => actions::remove_directory( + &mut config, + &options + .value_of_t_or_exit::("path") + .canonicalize()?, + ), ("list", _) => actions::list_directories(&config), ("status", _) => actions::show_status(&config), ("set", Some(options)) => actions::set_settings( @@ -136,7 +147,10 @@ fn main() -> Result<()> { method: options.value_of("method"), // We've already verified that the path is valid, so we should only be getting // errors for missing arguments - path: options.value_of_t("path").ok(), + path: options + .value_of_t::("path") + .ok() + .and_then(|path| path.canonicalize().ok()), }, ), ("sync", Some(options)) => actions::do_sync(