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 authored and wez committed May 15, 2024
1 parent f1a0842 commit 332b9b8
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 332b9b8

Please sign in to comment.