mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-26 10:07:32 +00:00
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)
This commit is contained in:
parent
97d1472331
commit
5189d66e2c
@ -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 @@
|
||||
[38;5;244m├──[0m escape: [[31m\u{1b}[0m]
|
||||
[38;5;244m├──[0m form-feed: [[31m\u{c}[0m]
|
||||
[38;5;244m├──[0m invalid-utf8-1: [<5B>]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-2: [<5B>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-3: [<5B>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-4: [<5B>(<28>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m [1;34mlinks[0m
|
||||
[38;5;244m│ ├──[0m [36manother: [[31m\n[36m][0m [38;5;244m->[0m [36m/testcases/file-names/new-line-dir: [[31m\n[36m]/[0manother: [[31m\n[0m]
|
||||
[38;5;244m│ ├──[0m [36mbroken[0m [31m->[0m [4;31m/testcases/file-names/new-line-dir: [\n]/broken[0m
|
||||
[38;5;244m│ │ └──[0m [31m<No such file or directory (os error 2)>[0m
|
||||
[38;5;244m│ └──[0m [36msubfile[0m [38;5;244m->[0m [36m/testcases/file-names/new-line-dir: [[31m\n[36m]/[0msubfile
|
||||
[38;5;244m├──[0m [1;34mnew-line-dir: [[0m[31m\n[1;34m][0m
|
||||
[38;5;244m│ ├──[0m another: [[31m\n[0m]
|
||||
|
29
xtests/file_names_T@
Normal file
29
xtests/file_names_T@
Normal file
@ -0,0 +1,29 @@
|
||||
[36m/testcases/[1;34mfile-names[0m
|
||||
[38;5;244m├──[0m ansi: [[31m\u{1b}[0m[34mblue[31m\u{1b}[0m[0m]
|
||||
[38;5;244m├──[0m ascii: hello
|
||||
[38;5;244m├──[0m backspace: [[31m\u{8}[0m]
|
||||
[38;5;244m├──[0m bell: [[31m\u{7}[0m]
|
||||
[38;5;244m├──[0m emoji: [🆒]
|
||||
[38;5;244m├──[0m escape: [[31m\u{1b}[0m]
|
||||
[38;5;244m├──[0m form-feed: [[31m\u{c}[0m]
|
||||
[38;5;244m├──[0m invalid-utf8-1: [<5B>]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-2: [<5B>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-3: [<5B>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m invalid-utf8-4: [<5B>(<28>(]
|
||||
[38;5;244m│ └──[0m [31m<Error: path somehow contained a NUL?>[0m
|
||||
[38;5;244m├──[0m [1;34mlinks[0m
|
||||
[38;5;244m│ ├──[0m [36manother: [[31m\n[36m][0m [38;5;244m->[0m [36m/testcases/file-names/new-line-dir: [[31m\n[36m]/[0manother: [[31m\n[0m]
|
||||
[38;5;244m│ ├──[0m [36mbroken[0m [31m->[0m [4;31m/testcases/file-names/new-line-dir: [\n]/broken[0m
|
||||
[38;5;244m│ │ └──[0m [31m<No such file or directory (os error 2)>[0m
|
||||
[38;5;244m│ └──[0m [36msubfile[0m [38;5;244m->[0m [36m/testcases/file-names/new-line-dir: [[31m\n[36m]/[0msubfile
|
||||
[38;5;244m├──[0m [1;34mnew-line-dir: [[0m[31m\n[1;34m][0m
|
||||
[38;5;244m│ ├──[0m another: [[31m\n[0m]
|
||||
[38;5;244m│ └──[0m subfile
|
||||
[38;5;244m├──[0m new-line: [[31m\n[0m]
|
||||
[38;5;244m├──[0m return: [[31m\r[0m]
|
||||
[38;5;244m├──[0m tab: [[31m\t[0m]
|
||||
[38;5;244m├──[0m utf-8: pâté
|
||||
[38;5;244m└──[0m vertical-tab: [[31m\u{b}[0m]
|
@ -1,11 +1,8 @@
|
||||
[36m/testcases/[1;34mlinks[0m
|
||||
[38;5;244m├──[0m [36mbroken[0m [31m->[0m [4;31mnowhere[0m
|
||||
[38;5;244m│ └──[0m [31m<No such file or directory (os error 2)>[0m
|
||||
[38;5;244m├──[0m [36mcurrent_dir[0m [38;5;244m->[0m [1;34m.[0m
|
||||
[38;5;244m├──[0m [36mforbidden[0m [31m->[0m [4;31m/proc/1/root[0m
|
||||
[38;5;244m│ └──[0m [31m<Permission denied (os error 13)>[0m
|
||||
[38;5;244m├──[0m [36mitself[0m [31m->[0m [4;31mitself[0m
|
||||
[38;5;244m│ └──[0m [31m<Too many levels of symbolic links (os error 40)>[0m
|
||||
[38;5;244m├──[0m [36mparent_dir[0m [38;5;244m->[0m [1;34m..[0m
|
||||
[38;5;244m├──[0m [36mroot[0m [38;5;244m->[0m [1;34m/[0m
|
||||
[38;5;244m├──[0m some_file
|
||||
|
14
xtests/links_T@
Normal file
14
xtests/links_T@
Normal file
@ -0,0 +1,14 @@
|
||||
[36m/testcases/[1;34mlinks[0m
|
||||
[38;5;244m├──[0m [36mbroken[0m [31m->[0m [4;31mnowhere[0m
|
||||
[38;5;244m│ └──[0m [31m<No such file or directory (os error 2)>[0m
|
||||
[38;5;244m├──[0m [36mcurrent_dir[0m [38;5;244m->[0m [1;34m.[0m
|
||||
[38;5;244m├──[0m [36mforbidden[0m [31m->[0m [4;31m/proc/1/root[0m
|
||||
[38;5;244m│ └──[0m [31m<Permission denied (os error 13)>[0m
|
||||
[38;5;244m├──[0m [36mitself[0m [31m->[0m [4;31mitself[0m
|
||||
[38;5;244m│ └──[0m [31m<Too many levels of symbolic links (os error 40)>[0m
|
||||
[38;5;244m├──[0m [36mparent_dir[0m [38;5;244m->[0m [1;34m..[0m
|
||||
[38;5;244m├──[0m [36mroot[0m [38;5;244m->[0m [1;34m/[0m
|
||||
[38;5;244m├──[0m some_file
|
||||
[38;5;244m├──[0m [36msome_file_absolute[0m [38;5;244m->[0m [36m/testcases/links/[0msome_file
|
||||
[38;5;244m├──[0m [36msome_file_relative[0m [38;5;244m->[0m some_file
|
||||
[38;5;244m└──[0m [36musr[0m [38;5;244m->[0m [36m/[1;34musr[0m
|
@ -1,2 +1 @@
|
||||
[36m/proc/1/root[0m
|
||||
[38;5;244m└──[0m [31m<Permission denied (os error 13)>[0m
|
||||
|
2
xtests/proc_1_root_@
Normal file
2
xtests/proc_1_root_@
Normal file
@ -0,0 +1,2 @@
|
||||
[36m/proc/1/root[0m
|
||||
[38;5;244m└──[0m [31m<Permission denied (os error 13)>[0m
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user