zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Tiny fix to zrecompile
@ 2000-09-03 20:19 Bart Schaefer
  2000-09-03 21:20 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2000-09-03 20:19 UTC (permalink / raw)
  To: zsh-workers

The -p option didn't work properly when the first word after it was an
option for the zcompile command; getopts would fail with "bad option".

Index: Functions/Misc/zrecompile
===================================================================
@@ -37,7 +37,7 @@
 
 local opt check quiet zwc files re file pre ret map tmp mesg pats
 
-while getopts "tqp" opt; do
+while getopts ":tqp" opt; do
   case $opt in
   t) check=yes ;;
   q) quiet=yes ;;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: PATCH: Tiny fix to zrecompile
  2000-09-03 20:19 PATCH: Tiny fix to zrecompile Bart Schaefer
@ 2000-09-03 21:20 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-09-03 21:20 UTC (permalink / raw)
  To: zsh-workers

On Sep 3,  8:19pm, Bart Schaefer wrote:
} Subject: PATCH: Tiny fix to zrecompile
}
} The -p option didn't work properly when the first word after it was an
} option for the zcompile command; getopts would fail with "bad option".

I just realized that this patch didn't go far enough.  The following is
a slight reworking to cause zrecompile to pass along any/all zcompile
options that may appear after -p.  Apply it after 12726.

--- zsh-forge/current/Functions/Misc/zrecompile	Sun Sep  3 14:02:19 2000
+++ zsh-3.1.9-dev-5/Functions/Misc/zrecompile	Sun Sep  3 14:18:50 2000
@@ -33,18 +33,26 @@
 # that needed re-compilation could be compiled and non-zero if compilation
 # for at least one of the files failed.
 
-setopt localoptions extendedglob
+setopt localoptions extendedglob noshwordsplit noksharrays
 
 local opt check quiet zwc files re file pre ret map tmp mesg pats
 
+tmp=()
 while getopts ":tqp" opt; do
   case $opt in
   t) check=yes ;;
   q) quiet=yes ;;
   p) pats=yes  ;;
+  *)
+    if [[ -n $pats ]]; then
+      tmp=( $tmp $OPTARG )
+    else
+      print -u2 zrecompile: bad option: -$OPTARG
+      return 1
+    fi
   esac
 done
-shift OPTIND-1
+shift OPTIND-${#tmp:-1}
 
 if [[ -n $check ]]; then
   ret=1
@@ -66,12 +74,16 @@
       argv=()
     fi
 
-    if [[ $files[1] = -[RM] ]]; then
-      map=( $files[1] )
-      shift 1 files
-    else
-      map=()
-    fi
+    tmp=()
+    map=()
+    OPTIND=1
+    while getopts :MR opt $files; do
+      case $opt in
+      [MR]) map=( -$opt ) ;;
+      *) tmp=( $tmp $files[OPTIND] );;
+      esac
+    done
+    shift OPTIND-1 files
     (( $#files )) || continue
 
     files=( $files[1] ${files[2,-1]:#*(.zwc|~)} )
@@ -117,7 +129,7 @@
 	# old file by renaming it.
 
 	if { [[ ! -f $zwc ]] || mv $zwc ${zwc}.old } &&
-             zcompile "$map[@]" $zwc $files 2> /dev/null; then
+             zcompile $map $tmp $zwc $files 2> /dev/null; then
           [[ -z $quiet ]] && print succeeded
         else
           [[ -z $quiet ]] && print failed

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2000-09-03 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-03 20:19 PATCH: Tiny fix to zrecompile Bart Schaefer
2000-09-03 21:20 ` Bart Schaefer

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).