Skip to content

Commit 82ca81a

Browse files
timaebimmlb
authored andcommitted
zpool: Split after \t instead of any space
Without things like dates (Wed Feb 21 12:51 2018) are split into multiple fields.
1 parent 81c92b4 commit 82ca81a

File tree

4 files changed

+3
-6
lines changed

4 files changed

+3
-6
lines changed

utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (c *command) Run(arg ...string) ([][]string, error) {
6161
output := make([][]string, len(lines))
6262

6363
for i, l := range lines {
64-
output[i] = strings.Fields(l)
64+
output[i] = strings.Split(l, "\t")
6565
}
6666

6767
return output, nil

utils_notsolaris.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ var (
1515
zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio", "fragmentation", "freeing", "leaked"}
1616

1717
zpoolPropListOptions = strings.Join(zpoolPropList, ",")
18-
zpoolArgs = []string{"get", "-p", zpoolPropListOptions}
18+
zpoolArgs = []string{"get", "-Hp", zpoolPropListOptions}
1919
)

utils_solaris.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ var (
1515
zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio"}
1616

1717
zpoolPropListOptions = strings.Join(zpoolPropList, ",")
18-
zpoolArgs = []string{"get", "-p", zpoolPropListOptions}
18+
zpoolArgs = []string{"get", "-Hp", zpoolPropListOptions}
1919
)

zpool.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ func GetZpool(name string) (*Zpool, error) {
4949
return nil, err
5050
}
5151

52-
// there is no -H
53-
out = out[1:]
54-
5552
z := &Zpool{Name: name}
5653
for _, line := range out {
5754
if err := z.parseLine(line); err != nil {

0 commit comments

Comments
 (0)