xattr: fix the failure on empty list
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
ed6b293839
commit
2685cd3cc5
1 changed files with 8 additions and 1 deletions
|
@ -29,7 +29,14 @@ func List(path string) ([]string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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"
|
const nilByte = "\x00"
|
||||||
|
|
Loading…
Reference in a new issue