about summary refs log tree commit diff
path: root/Src/Modules/files.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-13 12:35:16 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-13 12:35:16 +0000
commit79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901 (patch)
tree4d96376eddf9c56c3555bfe080e1b4a309851f2f /Src/Modules/files.c
parent8828798a99512469f569f4a3eb2c8606456e0ff0 (diff)
downloadzsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.tar.gz
zsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.tar.xz
zsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.zip
zsh-workers/9013
Diffstat (limited to 'Src/Modules/files.c')
-rw-r--r--Src/Modules/files.c11
1 files changed, 7 insertions, 4 deletions
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: