Skip to content

Commit ae752b4

Browse files
committed
sh: remove atty dependency
1 parent 703f3a8 commit ae752b4

File tree

4 files changed

+4
-27
lines changed

4 files changed

+4
-27
lines changed

Cargo.lock

-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sh/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2021"
77
plib = { path = "../plib" }
88
gettext-rs.workspace = true
99
libc.workspace = true
10-
atty = "0.2"
1110

1211
[[bin]]
1312
name = "sh"

sh/builtin/read.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::shell::opened_files::{OpenedFile, OpenedFiles, STDIN_FILENO};
1515
use crate::shell::Shell;
1616
use crate::wordexp::expanded_word::ExpandedWord;
1717
use crate::wordexp::split_fields;
18-
use atty::Stream;
18+
use std::io::IsTerminal;
1919
use std::os::fd::{AsRawFd, RawFd};
2020
use std::time::Duration;
2121

@@ -141,7 +141,7 @@ fn read_from_stdin(
141141
delimiter: u8,
142142
backslash_escape: bool,
143143
) -> Result<ReadResult, BuiltinError> {
144-
if atty::is(Stream::Stdin) {
144+
if std::io::stdin().is_terminal() {
145145
let original_terminal_settings = shell.terminal.reset();
146146
shell.terminal.set_nonblocking();
147147

sh/cli/terminal.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
//
99

1010
use crate::os::errno::get_current_errno_value;
11-
use atty::Stream;
1211
use std::io;
13-
use std::io::Read;
12+
use std::io::{IsTerminal, Read};
1413

1514
fn get_current_settings() -> libc::termios {
1615
// using zeroed here because terminos has additional members on some systems
@@ -98,5 +97,5 @@ pub fn read_nonblocking_char() -> Option<u8> {
9897
}
9998

10099
pub fn is_attached_to_terminal() -> bool {
101-
atty::is(Stream::Stdin) && atty::is(Stream::Stdout)
100+
std::io::stdin().is_terminal() && std::io::stdout().is_terminal()
102101
}

0 commit comments

Comments
 (0)