Skip to content

Commit

Permalink
Windows: fix warnings in pty crate
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwood committed May 15, 2024
1 parent f1a0842 commit 60b1547
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pty/src/cmdbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::collections::BTreeMap;
use std::ffi::{OsStr, OsString};
#[cfg(windows)]
use std::os::windows::ffi::OsStrExt;
use std::path::{Component, Path};
#[cfg(unix)]
use std::path::Component;
use std::path::Path;

/// Used to deal with Windows having case-insensitive environment variables.
#[derive(Clone, Debug, PartialEq, PartialOrd)]
Expand Down Expand Up @@ -605,8 +607,6 @@ impl CommandBuilder {
}

pub(crate) fn current_directory(&self) -> Option<Vec<u16>> {
use std::path::Path;

let home: Option<&OsStr> = self
.get_env("USERPROFILE")
.filter(|path| Path::new(path).is_dir());
Expand Down Expand Up @@ -745,6 +745,7 @@ impl CommandBuilder {
}
}

#[cfg(unix)]
/// Returns true if the path begins with `./` or `../`
fn is_cwd_relative_path<P: AsRef<Path>>(p: P) -> bool {
matches!(
Expand All @@ -757,6 +758,7 @@ fn is_cwd_relative_path<P: AsRef<Path>>(p: P) -> bool {
mod tests {
use super::*;

#[cfg(unix)]
#[test]
fn test_cwd_relative() {
assert!(is_cwd_relative_path("."));
Expand Down

0 comments on commit 60b1547

Please sign in to comment.