xattr: fix the failure on empty list

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-07-26 13:55:25 -04:00
parent ed6b293839
commit 2685cd3cc5
1 changed files with 8 additions and 1 deletions

View File

@ -29,7 +29,14 @@ func List(path string) ([]string, error) {
if err != nil {
return nil, err
}
return strings.Split(strings.TrimRight(string(dest[:i]), nilByte), nilByte), nil
// If the returned list is empty, return nil instead of []string{""}
str := string(dest[:i])
if str == "" {
return nil, nil
}
return strings.Split(strings.TrimRight(str, nilByte), nilByte), nil
}
const nilByte = "\x00"