From 79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 13 Dec 1999 12:35:16 +0000 Subject: zsh-workers/9013 --- Src/Modules/files.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Src/Modules') diff --git a/Src/Modules/files.c b/Src/Modules/files.c index 844ca7d25..ac3bedd04 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -628,21 +628,22 @@ bin_chown(char *nam, char **args, char *ops, int func) { struct chownmagic chm; char *uspec = ztrdup(*args), *p = uspec; + char *end; chm.nam = nam; if(func == BIN_CHGRP) { chm.uid = -1; goto dogroup; } - if(*p == ':' || *p == '.') { + end = strchr(uspec, ':'); + if(!end) + end = strchr(uspec, '.'); + if(end == uspec) { chm.uid = -1; p++; goto dogroup; } else { struct passwd *pwd; - char *end = strchr(p, ':'); - if(!end) - end = strchr(p, '.'); if(end) *end = 0; pwd = getpwnam(p); @@ -666,6 +667,8 @@ bin_chown(char *nam, char **args, char *ops, int func) return 1; } chm.gid = pwd->pw_gid; + } else if(p[0] == ':' && !p[1]) { + chm.gid = -1; } else { struct group *grp; dogroup: -- cgit 1.4.1