mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 22:14:53 +00:00
Switch to errno
crate
This commit is contained in:
parent
3dfc9082e6
commit
80c8bc75e6
1 changed files with 5 additions and 6 deletions
|
@ -1,9 +1,7 @@
|
||||||
//! Implementation of the realpath builtin.
|
//! Implementation of the realpath builtin.
|
||||||
|
|
||||||
use std::io::Error;
|
use errno::errno;
|
||||||
|
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use nix::errno::errno;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ffi::parser_t,
|
ffi::parser_t,
|
||||||
|
@ -98,14 +96,15 @@ pub fn realpath(
|
||||||
if let Some(real_path) = wrealpath(arg) {
|
if let Some(real_path) = wrealpath(arg) {
|
||||||
streams.out.append(real_path);
|
streams.out.append(real_path);
|
||||||
} else {
|
} else {
|
||||||
if errno() != 0 {
|
let errno = errno();
|
||||||
|
if errno.0 != 0 {
|
||||||
// realpath() just couldn't do it. Report the error and make it clear
|
// realpath() just couldn't do it. Report the error and make it clear
|
||||||
// this is an error from our builtin, not the system's realpath.
|
// this is an error from our builtin, not the system's realpath.
|
||||||
streams.err.append(wgettext_fmt!(
|
streams.err.append(wgettext_fmt!(
|
||||||
"builtin %ls: %ls: %s\n",
|
"builtin %ls: %ls: %s\n",
|
||||||
cmd,
|
cmd,
|
||||||
arg,
|
arg,
|
||||||
Error::last_os_error().to_string()
|
errno.to_string()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
// Who knows. Probably a bug in our wrealpath() implementation.
|
// Who knows. Probably a bug in our wrealpath() implementation.
|
||||||
|
@ -131,7 +130,7 @@ pub fn realpath(
|
||||||
streams.err.append(wgettext_fmt!(
|
streams.err.append(wgettext_fmt!(
|
||||||
"builtin %ls: realpath failed: %s\n",
|
"builtin %ls: realpath failed: %s\n",
|
||||||
cmd,
|
cmd,
|
||||||
std::io::Error::last_os_error().to_string()
|
errno().to_string()
|
||||||
));
|
));
|
||||||
return STATUS_CMD_ERROR;
|
return STATUS_CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue