[PATCH] completion: chown, cpio: support user:group syntax only

dana <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
i think this was inspired by a complaint on irc, but i've been sitting on it
for a few years

currently we handle . as a delimiter for chown and cpio, as in user.group.
this syntax has been deprecated/non-preferred for my entire life afaik. posix
says to use :. all bsd man pages for chown have said to use : since the '90s.
support for . has been disabled entirely in freebsd/darwin chown since the
early 2000s i think. gnu chown accepts it but it prints a warning message. the
man page on irix (special-cased in _chown) still mentioned . at the end but it
also supported :

anyway our trying to handle the . is annoying on systems that actually have
users/groups with dots in their names

rather than try to make it smarter i think it's ok to just stop supporting
that syntax

dana


diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index dae0de86c..36db9c4d2 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -74,19 +74,13 @@ _arguments -C -s -S -0 $aopts "$args[@]" '*: :->files' && ret=0
 
 case $state in
   owner)
-    if [[ $service = chgrp ]] || compset -P '*[:.]'; then
+    if [[ $service = chgrp ]] || compset -P '*:'; then
       if (( EGID && $+commands[groups] && ! $+_comp_priv_prefix )); then  # except for sudo
        _wanted groups expl 'group' compadd -- $(groups) && return 0
       fi
       _groups && ret=0
     else
-      if compset -S '[.:]*'; then
-        suf=()
-      elif [[ $OSTYPE = irix* ]]; then
-	suf=( -qS '.' )
-      else
-	suf=( -qS ':' )
-      fi
+      compset -S ':*' || suf=( -qS: )
       _users "$suf[@]" && ret=0
     fi
   ;;
@@ -102,9 +96,9 @@ case $state in
     if [[ $service = chgrp ]]; then
       grp=${line[1]}
     else
-      usr=${line[1]%%[.:]*}
+      usr=${line[1]%%:*}
       usr=${${(M)usr:#[0-9]#}:-${userdirs[$usr]:+.$usr.}}
-      grp=${${(M)line[1]%%[.:]*}#?}
+      grp=${${(M)line[1]%%:*}#?}
     fi
     [[ -n $grp ]] && grp="${${(M)grp:#[0-9]#}:-.$grp.}"
     req=( ${usr:+\^u$usr} ${grp:+\^g$grp} )
diff --git a/Completion/Unix/Command/_cpio b/Completion/Unix/Command/_cpio
index 20f8c712d..6db4994d8 100644
--- a/Completion/Unix/Command/_cpio
+++ b/Completion/Unix/Command/_cpio
@@ -120,13 +120,12 @@ if [[ $state = afile ]]; then
 	'users:user name:_users -qS@' && ret=0
   fi
 elif [[ $state = user ]]; then
-  if compset -P '*[:.]'; then
+  if compset -P '*:'; then
     _groups && ret=0
   else
-    local suf=.
-    [[ $OSTYPE = (solaris|hpux)* ]] && suf=:
-    compset -S '.*' && unset suf
-    _users -S "$suf" -q && ret=0
+    local suf
+    compset -S ':*' || suf=( -qS: )
+    _users $suf && ret=0
   fi
 fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.