Quote arguments when executing in a shell (#118)
* Quote arguments when executing in a shell Fixes #107 * Parse quotes in `tmux_arguments` This makes it possible to encode spaces in arguments. Maybe the config value should be an array instead? * Print error causes Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,6 @@ use std::fs::write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::{env, fs};
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{ArgEnum, Parser};
|
||||
use directories::BaseDirs;
|
||||
@@ -626,8 +625,16 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Extra Tmux arguments
|
||||
pub fn tmux_arguments(&self) -> &Option<String> {
|
||||
&self.config_file.tmux_arguments
|
||||
pub fn tmux_arguments(&self) -> anyhow::Result<Vec<String>> {
|
||||
let args = &self.config_file.tmux_arguments.as_deref().unwrap_or_default();
|
||||
shell_words::split(args)
|
||||
// The only time the parse failed is in case of a missing close quote.
|
||||
// The error message looks like this:
|
||||
// Error: Failed to parse `tmux_arguments`: `'foo`
|
||||
//
|
||||
// Caused by:
|
||||
// missing closing quote
|
||||
.with_context(|| format!("Failed to parse `tmux_arguments`: `{args}`"))
|
||||
}
|
||||
|
||||
/// Prompt for a key before exiting
|
||||
|
||||
Reference in New Issue
Block a user