summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2010-12-22 14:13:27 +0100
committerAndreas Gruenbacher <agruen@linbit.com>2011-05-27 14:26:38 +0200
commit93c92ed1d826c6759bb83d2168ee818a05280f35 (patch)
treeb0135b160603f2a4a1f2c3f16b2cbedcc0442ba3
parent2c053e75d44016dd6b07649a356c1ce55dbe1028 (diff)
downloadattr-93c92ed1d826c6759bb83d2168ee818a05280f35.tar.gz
getfattr: return non-zero exit code on failure
reported by Jean-Pierre André at https://bugzilla.redhat.com/660619
-rw-r--r--getfattr/getfattr.c7
-rw-r--r--test/attr.test4
2 files changed, 8 insertions, 3 deletions
diff --git a/getfattr/getfattr.c b/getfattr/getfattr.c
index 9c3de32..40f8fb5 100644
--- a/getfattr/getfattr.c
+++ b/getfattr/getfattr.c
@@ -353,6 +353,7 @@ int do_print(const char *path, const struct stat *stat, int walk_flags,
void *unused)
{
int header_printed = 0;
+ int err = 0;
if (walk_flags & WALK_TREE_FAILED) {
fprintf(stderr, "%s: %s: %s\n", progname, xquote(path, "\n\r"),
@@ -361,13 +362,13 @@ int do_print(const char *path, const struct stat *stat, int walk_flags,
}
if (opt_name)
- print_attribute(path, opt_name, &header_printed);
+ err = print_attribute(path, opt_name, &header_printed);
else
- list_attributes(path, &header_printed);
+ err = list_attributes(path, &header_printed);
if (header_printed)
puts("");
- return 0;
+ return err;
}
void help(void)
diff --git a/test/attr.test b/test/attr.test
index 4a14c2f..cdec1b3 100644
--- a/test/attr.test
+++ b/test/attr.test
@@ -22,6 +22,10 @@ Try various valid and invalid names
> user.name
>
+ $ setfattr -x user.name f
+ $ sh -c 'getfattr -n user.name f && echo zero exit code'
+ > f: user.name: No such attribute
+
$ setfattr -n user.n -v value f
$ rm f