zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _date revisited
@ 2005-09-07 19:01 Clint Adams
  2005-09-09 10:53 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Clint Adams @ 2005-09-07 19:01 UTC (permalink / raw)
  To: zsh-workers

Solaris 9 and FreeBSD 4.11.

Index: Completion/Unix/Command/_date
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_date,v
retrieving revision 1.1
diff -u -r1.1 _date
--- Completion/Unix/Command/_date	3 Sep 2005 00:17:02 -0000	1.1
+++ Completion/Unix/Command/_date	7 Sep 2005 19:00:28 -0000
@@ -1,6 +1,7 @@
 #compdef date
 
-_arguments \
+if _pick_variant -r is_gnu gnu="Free Software Foundation" unix --version; then
+  _arguments \
     '-d[date]:time string:' \
     '-f[file]:date file:_files' \
     '-I[iso-8601]:time spec:' \
@@ -12,3 +13,26 @@
     '*=FILE*:file:_files' \
     '*=DATEFILE*:date file:_files' \
     ':format or date:'
+else
+  case "$OSTYPE" in
+	  (solaris*)
+	  _arguments \
+	    '-u[utc]' \
+	    '-a:adjustment:' \
+            ':format or date:'
+	  ;;
+	  (freebsd*)
+	  _arguments \
+	    '-u[utc]' \
+	    '-j[do not try to set date]' \
+	    '-n[only set time on current machine]' \
+	    '-d:daylight savingg time value:' \
+	    '-f:parsing format:' \
+	    '-r:seconds since epoch:' \
+	    '-t:minutes west of GMT:' \
+	    '-v:adjustment value:' \
+            ':format or date:'
+	  ;;
+  esac
+fi
+


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: _date revisited
  2005-09-07 19:01 PATCH: _date revisited Clint Adams
@ 2005-09-09 10:53 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2005-09-09 10:53 UTC (permalink / raw)
  To: zsh-workers

Clint Adams wrote:
> Solaris 9 and FreeBSD 4.11.
> 
> Index: Completion/Unix/Command/_date
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_date,v
> retrieving revision 1.1
> diff -u -r1.1 _date
> --- Completion/Unix/Command/_date	3 Sep 2005 00:17:02 -0000	1.1
> +++ Completion/Unix/Command/_date	7 Sep 2005 19:00:28 -0000
> @@ -1,6 +1,7 @@
>  #compdef date
>  
> -_arguments \
> +if _pick_variant -r is_gnu gnu="Free Software Foundation" unix --version; then

You don't need -r is_gnu unless you're wanting to save the result of
_pick_variant. If used, you'd need to declare is_gnu local.

It is also a good idea to include a fallback for functions that check
$OSTYPE so that something is done on other systems. Following patch does
a bit of reindenting, and rearranging.

Oliver

Index: Completion/Unix/Command/_date
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_date,v
retrieving revision 1.3
diff -u -r1.3 _date
--- Completion/Unix/Command/_date	7 Sep 2005 19:12:53 -0000	1.3
+++ Completion/Unix/Command/_date	9 Sep 2005 10:49:41 -0000
@@ -1,48 +1,48 @@
 #compdef date
 
-if _pick_variant -r is_gnu gnu="Free Software Foundation" unix --version; then
-  _arguments \
-    '-d[date]:time string:' \
-    '-f[file]:date file:_files' \
-    '-I[iso-8601]:time spec:' \
-    '-r[reference]:file:_files' \
-    '-R[rfc-2822]' \
-    '-s[set]:time string:' \
-    '-u[utc]' \
-    -- \
-    '*=FILE*:file:_files' \
-    '*=DATEFILE*:date file:_files' \
-    ':format or date:'
+local -a args
+
+if _pick_variant gnu="Free Software Foundation" unix --version; then
+  args=(
+    '-d[output specified date]:time string'
+    '-f[output dates specified in file]:file:_files'
+    '-I-[iso-8601]:precision:(date hours minutes seconds)'
+    '-r[reference]:file:_files'
+    '-R[rfc-2822]'
+    '-s[set]:time string'
+    --
+    '*=FILE*:file:_files'
+    '*=DATEFILE*:date file:_files'
+  )
 else
   case "$OSTYPE" in
-	  (solaris*)
-	  _arguments \
-	    '-u[utc]' \
-	    '-a:adjustment:' \
-            ':format or date:'
-	  ;;
-	  (freebsd*)
-	  _arguments \
-	    '-u[utc]' \
-	    '-n[only set time on current machine]' \
-	    '-d:daylight savingg time value:' \
-	    '-j[do not try to set date]' \
-	    '-f:parsing format:' \
-	    '-r:seconds since epoch:' \
-	    '-t:minutes west of GMT:' \
-	    '-v:adjustment value:' \
-            ':format or date:'
-	  ;;
-	  (openbsd*)
-	  _arguments \
-	    '-u[utc]' \
-	    '-n[only set time on current machine]' \
-	    '-d:daylight savingg time value:' \
-	    '-a[gradually skew]' \
-	    '-r:seconds since epoch:' \
-	    '-t:minutes west of GMT:' \
-            ':format or date:'
-	  ;;
+    solaris*)
+      args=( '-a:adjustment' )
+    ;;
+    freebsd*)
+      args=(
+	'-n[only set time on current machine]'
+	'-d:daylight saving time value'
+	'-j[do not try to set date]'
+	'-f:parsing format'
+	'-r:seconds since epoch'
+	'-t:minutes west of GMT'
+	'-v:adjustment value'
+      )
+    ;;
+    openbsd*)
+      args=(
+	'-n[only set time on current machine]'
+	'-d:daylight saving time value'
+	'-a[gradually skew]'
+	'-r:seconds since epoch'
+	'-t:minutes west of GMT'
+      )
+    ;;
   esac
 fi
 
+_arguments \
+  '-u[display or set time in UTC]' \
+  ':format or date' \
+  $args[@]


This message has been scanned for viruses by MailControl - www.mailcontrol.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-09 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-07 19:01 PATCH: _date revisited Clint Adams
2005-09-09 10:53 ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).