diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-12-13 12:35:16 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-12-13 12:35:16 +0000 |
commit | 79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901 (patch) | |
tree | 4d96376eddf9c56c3555bfe080e1b4a309851f2f | |
parent | 8828798a99512469f569f4a3eb2c8606456e0ff0 (diff) | |
download | zsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.tar.gz zsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.tar.xz zsh-79e1686a12e7ed0a3a2ae7372e4a3320ebd5f901.zip |
zsh-workers/9013
-rw-r--r-- | Doc/Zsh/mod_files.yo | 7 | ||||
-rw-r--r-- | Src/Modules/files.c | 11 |
2 files changed, 13 insertions, 5 deletions
diff --git a/Doc/Zsh/mod_files.yo b/Doc/Zsh/mod_files.yo index 356696faa..d5c87b6d1 100644 --- a/Doc/Zsh/mod_files.yo +++ b/Doc/Zsh/mod_files.yo @@ -17,12 +17,17 @@ The var(user-spec) can be in four forms: startsitem() sitem(var(user))(change owner to var(user); do not change group) +sitem(var(user)tt(::))(change owner to var(user); do not change group) sitem(var(user)tt(:))(change owner to var(user); change group to var(user)'s primary group) sitem(var(user)tt(:)var(group))(change owner to var(user); change group to var(group)) sitem(tt(:)var(group))(do not change owner; change group to var(group)) endsitem() -In each case, the `tt(:)' may instead be a `tt(.)'. +In each case, the `tt(:)' may instead be a `tt(.)'. The rule is that +if there is a `tt(:)' then the separator is `tt(:)', otherwise +if there is a `tt(.)' then the separator is `tt(.)', otherwise +there is no separator. + Each of var(user) and var(group) may be either a username (or group name, as appropriate) or a decimal user ID (group ID). Interpretation as a name takes precedence, if there is an all-numeric username (or group name). 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: |