Fixes issue with errors in file-stat when getting owner and group
This commit is contained in:
parent
e2abc4b19c
commit
3247a5db41
21
lib.go
21
lib.go
@ -1873,8 +1873,21 @@ var stdLibrary = vars{
|
||||
stat := info.Sys().(*syscall.Stat_t)
|
||||
u := strconv.FormatUint(uint64(stat.Uid), 10)
|
||||
g := strconv.FormatUint(uint64(stat.Gid), 10)
|
||||
usr, _ := user.LookupId(u)
|
||||
group, _ := user.LookupGroupId(g)
|
||||
var userString string
|
||||
usr, err := user.LookupId(u)
|
||||
if err != nil {
|
||||
userString = ""
|
||||
} else {
|
||||
userString = usr.Username
|
||||
}
|
||||
|
||||
var groupString string
|
||||
group, err := user.LookupGroupId(g)
|
||||
if err != nil {
|
||||
groupString = ""
|
||||
} else {
|
||||
groupString = group.Name
|
||||
}
|
||||
|
||||
out := make([]expression, 10)
|
||||
out[0] = []expression{"name", info.Name()}
|
||||
@ -1884,8 +1897,8 @@ var stdLibrary = vars{
|
||||
out[4] = []expression{"is-dir?", info.IsDir()}
|
||||
out[5] = []expression{"is-symlink?", false}
|
||||
out[6] = []expression{"path", fp}
|
||||
out[7] = []expression{"owner", usr.Username}
|
||||
out[8] = []expression{"group", group.Name}
|
||||
out[7] = []expression{"owner", userString}
|
||||
out[8] = []expression{"group", groupString}
|
||||
out[9] = []expression{"modestring", strconv.FormatUint(uint64(info.Mode()), 8)}
|
||||
|
||||
ln, err := os.Readlink(fp)
|
||||
|
2
main.go
2
main.go
@ -18,7 +18,7 @@ import (
|
||||
ln "github.com/peterh/liner"
|
||||
)
|
||||
|
||||
const version = "1.0.5"
|
||||
const version = "1.0.6"
|
||||
|
||||
const globalLibPath = "/usr/local/lib/slope/modules/"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user