Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: disable some unix-only helper functions on Windows #3650

Merged
merged 2 commits into from
Jan 25, 2024
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
8 changes: 5 additions & 3 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process;
use std::str::FromStr;

use anyhow::{anyhow, Error, Result};
Expand All @@ -24,7 +23,6 @@ use crate::{
currentprocess::{
argsource::ArgSource,
filesource::{StderrSource, StdoutSource},
varsource::VarSource,
},
dist::{
dist::{PartialToolchainDesc, Profile, TargetTriple},
Expand Down Expand Up @@ -212,6 +210,7 @@ pub fn main() -> Result<utils::ExitCode> {
("run", m) => run(cfg, m)?,
("which", m) => which(cfg, m)?,
("doc", m) => doc(cfg, m)?,
#[cfg(not(windows))]
("man", m) => man(cfg, m)?,
("self", c) => match c.subcommand() {
Some(s) => match s {
Expand Down Expand Up @@ -1615,7 +1614,10 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
}
}

#[cfg(not(windows))]
fn man(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
use crate::currentprocess::varsource::VarSource;

let command = m.get_one::<String>("command").unwrap();

let toolchain = explicit_desc_or_dir_toolchain(cfg, m)?;
Expand All @@ -1629,7 +1631,7 @@ fn man(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
if let Some(path) = process().var_os("MANPATH") {
manpaths.push(path);
}
process::Command::new("man")
std::process::Command::new("man")
.env("MANPATH", manpaths)
.arg(command)
.status()
Expand Down
12 changes: 7 additions & 5 deletions src/dist/dist.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::collections::HashSet;
use std::env;
use std::fmt;
use std::fs;
use std::io::{self, Read, Write};
use std::io::Write;
use std::ops::Deref;
use std::path::Path;
use std::str::FromStr;
Expand Down Expand Up @@ -238,10 +237,13 @@ impl Deref for TargetTriple {
}
}

/// Check if /bin/sh is a 32-bit binary. If it doesn't exist, fall back to
/// checking if _we_ are a 32-bit binary.
/// rustup-init.sh also relies on checking /bin/sh for bitness.
#[cfg(not(windows))]
fn is_32bit_userspace() -> bool {
// Check if /bin/sh is a 32-bit binary. If it doesn't exist, fall back to
// checking if _we_ are a 32-bit binary.
// rustup-init.sh also relies on checking /bin/sh for bitness.
use std::fs;
use std::io::{self, Read};

// inner function is to simplify error handling.
fn inner() -> io::Result<bool> {
Expand Down