From 3b519377c7a6830a17c55980500fb1371ffde9c7 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Wed, 30 Nov 2022 23:26:55 +0100 Subject: [PATCH] Fix panic on commands containing only spaces (#442) * Fix panic on commands containing only spaces * Add trim --- src/usr/shell.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/usr/shell.rs b/src/usr/shell.rs index 469ad64d5..7d9eab12b 100644 --- a/src/usr/shell.rs +++ b/src/usr/shell.rs @@ -356,7 +356,11 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> { let cmd = variables_expansion(cmd, config); - let mut args = split_args(&cmd); + let mut args = split_args(&cmd.trim()); + + if args.is_empty() { + return Ok(()); + } // Replace command alias if let Some(alias) = config.aliases.get(&args[0]) {