Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/commands/introspection.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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());
Expand All @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/commands/pwd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::commands::BuiltinResult;
use crate::path::display_path;
use anyhow::Result;
use std::env;

pub(crate) fn run() -> Result<BuiltinResult> {
Ok(BuiltinResult::stdout(
0,
format!("{}\n", display_path(&env::current_dir()?)).into_bytes(),
format!("{}\n", env::current_dir()?.display()).into_bytes(),
))
}
5 changes: 0 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn repl(mut shell: Shell) -> Result<i32> {
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,
Expand Down
6 changes: 1 addition & 5 deletions src/path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::{Path, PathBuf};
use std::path::PathBuf;

pub(crate) fn shell_path(path: &str) -> PathBuf {
#[cfg(windows)]
Expand All @@ -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<PathBuf> {
let path = path.replace('\\', "/");
Expand Down
Loading