summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzwPapEr <zw.paper@gmail.com>2020-04-05 18:27:01 +0800
committerAbin Simon <abinsimon10@gmail.com>2020-04-07 12:25:11 +0530
commit645be4a668fad2d08e1017cdd0e995b3f808dd37 (patch)
tree306787fba79a7fb19071955c4c033a96ce0d4ef2
parentad25edcd7e5d1490394082af99ae94c0e42635b1 (diff)
delete fs canonicalize for show broken softlink without error
fix https://github.com/Peltoche/lsd/issues/72
-rw-r--r--src/core.rs6
-rw-r--r--src/main.rs4
-rw-r--r--tests/integration.rs23
3 files changed, 27 insertions, 6 deletions
diff --git a/src/core.rs b/src/core.rs
index 6a120b3..57f653d 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -4,7 +4,6 @@ use crate::flags::{Display, Flags, IconTheme, Layout, WhenFlag};
use crate::icon::{self, Icons};
use crate::meta::Meta;
use crate::{print_error, print_output, sort};
-use std::fs;
use std::path::PathBuf;
#[cfg(not(target_os = "windows"))]
@@ -83,11 +82,6 @@ impl Core {
};
for path in paths {
- if let Err(err) = fs::canonicalize(&path) {
- print_error!("cannot access '{}': {}", path.display(), err);
- continue;
- }
-
let mut meta = match Meta::from_path(&path) {
Ok(meta) => meta,
Err(err) => {
diff --git a/src/main.rs b/src/main.rs
index 5251884..e1537ce 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -84,6 +84,10 @@ macro_rules! print_output {
fn main() {
let matches = app::build().get_matches_from(wild::args_os());
+ // input translate glob FILE without single quote into real names
+ // for example:
+ // * to all files matched
+ // '*' remain as '*'
let inputs = matches
.values_of("FILE")
.expect("failed to retrieve cli value")
diff --git a/tests/integration.rs b/tests/integration.rs
index 05dfa95..8d38fc7 100644
--- a/tests/integration.rs
+++ b/tests/integration.rs
@@ -6,6 +6,9 @@ use assert_fs::prelude::*;
use predicates::prelude::*;
use std::process::Command;
+#[cfg(unix)]
+use std::os::unix::fs;
+
#[test]
fn test_runs_okay() {
cmd().assert().success();
@@ -134,6 +137,26 @@ fn test_list_inode_with_long_ok() {
cmd().arg("-i").arg("-l").arg(dir.path()).assert().success();
}
+#[cfg(unix)]
+#[test]
+fn test_list_broken_link_ok() {
+ let dir = tempdir();
+ let broken_link = dir.path().join("broken-softlink");
+ let matched = "No such file or directory";
+ fs::symlink("not-existed-file", &broken_link).unwrap();
+
+ cmd()
+ .arg(&broken_link)
+ .assert()
+ .stderr(predicate::str::contains(matched).not());
+
+ cmd()
+ .arg("-l")
+ .arg(broken_link)
+ .assert()
+ .stderr(predicate::str::contains(matched).not());
+}
+
fn cmd() -> Command {
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
}