diff --git a/src/commands/introspection.rs b/src/commands/introspection.rs index d440206..c97817a 100644 --- a/src/commands/introspection.rs +++ b/src/commands/introspection.rs @@ -1,5 +1,4 @@ use crate::commands::{BuiltinResult, is_builtin}; -use crate::path::display_path; use crate::runtime::Shell; pub(crate) fn command(shell: &Shell, argv: &[String]) -> BuiltinResult { @@ -26,7 +25,7 @@ pub(crate) fn type_(shell: &Shell, argv: &[String]) -> BuiltinResult { if is_builtin(name) { stdout.extend_from_slice(format!("{name} is a shell builtin\n").as_bytes()); } else if let Some(path) = shell.resolve_program(name) { - stdout.extend_from_slice(format!("{name} is {}\n", display_path(&path)).as_bytes()); + stdout.extend_from_slice(format!("{name} is {}\n", path.display()).as_bytes()); } else { status = 1; stderr.extend_from_slice(format!("type: {name}: not found\n").as_bytes()); @@ -49,7 +48,7 @@ fn command_v(shell: &Shell, names: &[String]) -> BuiltinResult { if is_builtin(name) { stdout.extend_from_slice(format!("{name}\n").as_bytes()); } else if let Some(path) = shell.resolve_program(name) { - stdout.extend_from_slice(format!("{}\n", display_path(&path)).as_bytes()); + stdout.extend_from_slice(format!("{}\n", path.display()).as_bytes()); } else { status = 1; } diff --git a/src/commands/pwd.rs b/src/commands/pwd.rs index ee69c6b..c47bf42 100644 --- a/src/commands/pwd.rs +++ b/src/commands/pwd.rs @@ -1,11 +1,10 @@ use crate::commands::BuiltinResult; -use crate::path::display_path; use anyhow::Result; use std::env; pub(crate) fn run() -> Result { Ok(BuiltinResult::stdout( 0, - format!("{}\n", display_path(&env::current_dir()?)).into_bytes(), + format!("{}\n", env::current_dir()?.display()).into_bytes(), )) } diff --git a/src/lib.rs b/src/lib.rs index 96d4656..e4cbc2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,11 +5,6 @@ mod runtime; pub use runtime::{RunOptions, Shell}; -#[doc(hidden)] -pub fn display_path_for_cli(path: &std::path::Path) -> String { - self::path::display_path(path) -} - #[doc(hidden)] pub fn path_for_cli(path: &str) -> std::path::PathBuf { self::path::shell_path(path) diff --git a/src/main.rs b/src/main.rs index 7c5a47d..950e822 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,7 @@ fn repl(mut shell: Shell) -> Result { println!("NOTE: shell is only tuned for Windows."); loop { - let prompt = format!("{}> ", shell::display_path_for_cli(&env::current_dir()?)); + let prompt = format!("{}> ", env::current_dir()?.display()); let line = match terminal.read_line(&prompt)? { LineRead::Line(line) => line, LineRead::Interrupted => continue, diff --git a/src/path.rs b/src/path.rs index 6c14761..a5f1199 100644 --- a/src/path.rs +++ b/src/path.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::PathBuf; pub(crate) fn shell_path(path: &str) -> PathBuf { #[cfg(windows)] @@ -14,10 +14,6 @@ pub(crate) fn is_explicit_path(path: &str) -> bool { path.contains('/') || windows_drive_prefix(&path) } -pub(crate) fn display_path(path: &Path) -> String { - path.display().to_string().replace('\\', "/") -} - #[cfg(windows)] fn msys_drive_path(path: &str) -> Option { let path = path.replace('\\', "/");