Skip to content
Permalink
Browse files

Hide xattr errors unless --extended

exa now ignores errors when checking for extended attributes when the user didn’t explicitly demand that they be checked. If a file does have xattrs, it’ll still display the @ in the permissions column; errors will now just cause the @ to be hidden instead.

This changed a lot of the xtests, which were displaying the error message in a few situations. Those tests have gained @-suffixed companions so the actual error messages can still be tested.

Fixes #178 (finally)
  • Loading branch information...
ogham committed Aug 11, 2017
1 parent 97d1472 commit 5189d66e2ca0be83df5ba6c05587b792a0377067
Showing with 79 additions and 19 deletions.
  1. +22 −1 src/output/details.rs
  2. +0 −5 xtests/file_names_T
  3. +29 −0 xtests/file_names_T@
  4. +0 −3 xtests/links_T
  5. +14 −0 xtests/links_T@
  6. +0 −1 xtests/proc_1_root
  7. +2 −0 xtests/proc_1_root_@
  8. +12 −9 xtests/run.sh
@@ -191,10 +191,31 @@ impl<'a> Render<'a> {
let mut errors = Vec::new();
let mut xattrs = Vec::new();

// There are three “levels” of extended attribute support:
//
// 1. If we’re compiling without that feature, then
// exa pretends no files have attributes.
// 2. If the feature is enabled but the --extended flag
// hasn’t been specified, then display an @ in the
// permissions column for files with xattrs, but don’t
// display anything else.
// 3. If the --extended flag *has* been specified, then
// display the @, the attributes and their lengths,
// and any errors encountered when getting them.
//
// For a while, exa took a stricter approach to (2): if
// an error occurred while checking a file’s xattrs, exa
// would display that error even though the attributes
// weren’t actually being shown! This was confusing, as
// users were being shown errors for something they didn’t
// explicitly ask for, and just cluttered up the output.
// So now errors aren’t printed unless the user passes
// --extended to signify that they want to see them.

if xattr::ENABLED {
match file.path.attributes() {
Ok(xs) => xattrs.extend(xs),
Err(e) => errors.push((e, None)),
Err(e) => if self.opts.xattr { errors.push((e, None)) },
};
}

@@ -7,17 +7,12 @@
├── escape: [\u{1b}]
├── form-feed: [\u{c}]
├── invalid-utf8-1: [�]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-2: [�(]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-3: [�(]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-4: [�(�(]
│ └── <Error: path somehow contained a NUL?>
├── links
│ ├── another: [\n] -> /testcases/file-names/new-line-dir: [\n]/another: [\n]
│ ├── broken -> /testcases/file-names/new-line-dir: [\n]/broken
│ │ └── <No such file or directory (os error 2)>
│ └── subfile -> /testcases/file-names/new-line-dir: [\n]/subfile
├── new-line-dir: [\n]
│ ├── another: [\n]
@@ -0,0 +1,29 @@
/testcases/file-names
├── ansi: [\u{1b}[34mblue\u{1b}[0m]
├── ascii: hello
├── backspace: [\u{8}]
├── bell: [\u{7}]
├── emoji: [🆒]
├── escape: [\u{1b}]
├── form-feed: [\u{c}]
├── invalid-utf8-1: [�]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-2: [�(]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-3: [�(]
│ └── <Error: path somehow contained a NUL?>
├── invalid-utf8-4: [�(�(]
│ └── <Error: path somehow contained a NUL?>
├── links
│ ├── another: [\n] -> /testcases/file-names/new-line-dir: [\n]/another: [\n]
│ ├── broken -> /testcases/file-names/new-line-dir: [\n]/broken
│ │ └── <No such file or directory (os error 2)>
│ └── subfile -> /testcases/file-names/new-line-dir: [\n]/subfile
├── new-line-dir: [\n]
│ ├── another: [\n]
│ └── subfile
├── new-line: [\n]
├── return: [\r]
├── tab: [\t]
├── utf-8: pâté
└── vertical-tab: [\u{b}]
@@ -1,11 +1,8 @@
/testcases/links
├── broken -> nowhere
│ └── <No such file or directory (os error 2)>
├── current_dir -> .
├── forbidden -> /proc/1/root
│ └── <Permission denied (os error 13)>
├── itself -> itself
│ └── <Too many levels of symbolic links (os error 40)>
├── parent_dir -> ..
├── root -> /
├── some_file
@@ -0,0 +1,14 @@
/testcases/links
├── broken -> nowhere
│ └── <No such file or directory (os error 2)>
├── current_dir -> .
├── forbidden -> /proc/1/root
│ └── <Permission denied (os error 13)>
├── itself -> itself
│ └── <Too many levels of symbolic links (os error 40)>
├── parent_dir -> ..
├── root -> /
├── some_file
├── some_file_absolute -> /testcases/links/some_file
├── some_file_relative -> some_file
└── usr -> /usr
@@ -1,2 +1 @@
/proc/1/root
└── <Permission denied (os error 13)>
@@ -0,0 +1,2 @@
/proc/1/root
└── <Permission denied (os error 13)>
@@ -86,11 +86,12 @@ sudo -u cassowary $exa $testcases/permissions -lghR 2>&1 | diff -q - $results/pe

# File names
# (Mostly escaping control characters in file names)
COLUMNS=80 $exa $testcases/file-names 2>&1 | diff -q - $results/file_names || exit 1
COLUMNS=80 $exa $testcases/file-names -x 2>&1 | diff -q - $results/file_names_x || exit 1
COLUMNS=80 $exa $testcases/file-names -R 2>&1 | diff -q - $results/file_names_R || exit 1
$exa $testcases/file-names -1 2>&1 | diff -q - $results/file_names_1 || exit 1
$exa $testcases/file-names -T 2>&1 | diff -q - $results/file_names_T || exit 1
COLUMNS=80 $exa $testcases/file-names 2>&1 | diff -q - $results/file_names || exit 1
COLUMNS=80 $exa $testcases/file-names -x 2>&1 | diff -q - $results/file_names_x || exit 1
COLUMNS=80 $exa $testcases/file-names -R 2>&1 | diff -q - $results/file_names_R || exit 1
$exa $testcases/file-names -1 2>&1 | diff -q - $results/file_names_1 || exit 1
$exa $testcases/file-names -T 2>&1 | diff -q - $results/file_names_T || exit 1
$exa $testcases/file-names -T@ 2>&1 | diff -q - $results/file_names_T@ || exit 1

# At least make sure it handles invalid UTF-8 arguments without crashing
$exa $testcases/file-names/* >/dev/null || exit 1
@@ -144,10 +145,12 @@ env LANG=ja_JP.UTF-8 $exa $testcases/dates -l | diff -q - $results/dates_jp ||


# Links
COLUMNS=80 $exa $testcases/links 2>&1 | diff -q - $results/links || exit 1
$exa $testcases/links -1 2>&1 | diff -q - $results/links_1 || exit 1
$exa $testcases/links -T 2>&1 | diff -q - $results/links_T || exit 1
$exa /proc/1/root -T 2>&1 | diff -q - $results/proc_1_root || exit 1
COLUMNS=80 $exa $testcases/links 2>&1 | diff -q - $results/links || exit 1
$exa $testcases/links -1 2>&1 | diff -q - $results/links_1 || exit 1
$exa $testcases/links -T 2>&1 | diff -q - $results/links_T || exit 1
$exa $testcases/links -T@ 2>&1 | diff -q - $results/links_T@ || exit 1
$exa /proc/1/root -T 2>&1 | diff -q - $results/proc_1_root || exit 1
$exa /proc/1/root -T@ 2>&1 | diff -q - $results/proc_1_root_@ || exit 1

# There’ve been bugs where the target file wasn’t printed properly when the
# symlink file was specified on the command-line directly.

0 comments on commit 5189d66

Please sign in to comment.
You can’t perform that action at this time.