File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 88//
99
1010use std:: ffi:: CString ;
11+ use std:: io:: IsTerminal ;
12+ use std:: os:: fd:: BorrowedFd ;
1113use std:: os:: unix:: fs:: { FileTypeExt , MetadataExt , PermissionsExt } ;
1214use std:: path:: Path ;
1315
@@ -156,17 +158,15 @@ fn eval_unary_path(op: &UnaryOp, s: &str) -> bool {
156158}
157159
158160fn eval_terminal ( s : & str ) -> bool {
159- let fd = match s. parse :: < u32 > ( ) {
161+ let fd = match s. parse :: < i32 > ( ) {
160162 Ok ( f) => f,
161163 Err ( _) => {
162164 return false ;
163165 }
164166 } ;
165167
166- // Normally, posixutils would use the atty crate.
167- // Passing an arbitrary fd requires unsafe isatty in this case.
168-
169- unsafe { libc:: isatty ( fd as i32 ) == 1 }
168+ // Use safe Rust IsTerminal trait with BorrowedFd
169+ unsafe { BorrowedFd :: borrow_raw ( fd) . is_terminal ( ) }
170170}
171171
172172fn eval_unary ( op_str : & str , s : & str ) -> bool {
You can’t perform that action at this time.
0 commit comments