diff --git a/src/shell/binary.rs b/src/shell/binary.rs index 88f09efdf5dd87ad1a573df71c80786859657c6e..b2271972cb79ce8dc480af35590f9117d16269ac 100644 --- a/src/shell/binary.rs +++ b/src/shell/binary.rs @@ -328,12 +328,17 @@ impl<'a> Binary for Shell<'a> { if let Ok(command) = self.terminate_quotes(command) { let cmd = command.trim(); self.on_command(cmd); - + if cmd.starts_with('~') { - if let Some(ref cmd) = self.variables.tilde_expansion(cmd, &self.directory_stack) { + if !cmd.ends_with('/') && self.variables + .tilde_expansion(cmd, &self.directory_stack) + .map_or(false, |ref path| Path::new(path).is_dir()) + { self.save_command_in_history(&[cmd, "/"].concat()); - continue + } else { + self.save_command_in_history(cmd); } + continue } if Path::new(cmd).is_dir() & !cmd.ends_with('/') {