From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id KAA17258 for ; Sun, 14 Jul 1996 10:48:20 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id UAA29280; Sat, 13 Jul 1996 20:33:50 -0400 (EDT) Resent-Date: Sat, 13 Jul 1996 20:33:50 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960713173425.ZM5697@candle.brasslantern.com> Date: Sat, 13 Jul 1996 17:34:22 -0700 Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.702 02jul96) To: zsh-workers@math.gatech.edu Subject: Another patch to compctl-examples CVS compctl, and a bug? Cc: bobg@zanshin.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"QOmu23.0.Q97.k14wn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1639 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu It's now possible to avoid several external processes in generating the list of CVS-controlled files in the `cvstargets' function. The key is this wonderful "parameter" (boy, is that misnamed) subsitution: "${${${(f@)$({<${pref}CVS/Entries} 2>/dev/null)}#/}%%/*}" This almost bears explaining in and of itself. The {...} are needed around the nullcmd input redirection, so that the 2> redirection won't be improperly parsed as part of the file name (see my previous report). The $(...) substitution grabs the contents of the CVS/Entries file to get a list of all files in the current directory that CVS knows about. This is wrapped in ${(f@)...} to force each line to be interpreted as a separate word; this works because of the outer double quotes. Next is ${...#/} to strip a leading slash from every line of the CVS/Entries file. Finally, this is wrapped in ${...%%/*} to strip from each line everything following the file name itself. If there's a better way than `for f in ... do echo ... done' to prefix every element of the resulting array with ${pref}, I'd love to see it. Now for the bug: If the ${pref}CVS/Entries file exists, all of this works fine. However, if no CVS directory exists at all, the above subsitution prints a newline to the terminal -- which messes up zle. The newline is not going into $reply, because using or and then continuing a menu completion cycles through the other choices without further zle confusion. Where is that newline coming from? The other interesting (and the slow) part of $reply is: ${pref}*/**/CVS(:h) which returns names of any directories below the ${pref} directory that in turn contain a CVS subdirectory. Hmm, maybe all that should get added to the comments in the file. :-} *** Misc/compctl-examples.0 Fri Jul 5 10:57:42 1996 --- Misc/compctl-examples Sat Jul 13 16:50:40 1996 *************** *** 439,447 **** pref= fi [[ -n "$pref" && "$pref" != */ ]] && pref=$pref/ ! reply=($(for f in $(cat ${pref}CVS/Entries 2>/dev/null | \ ! sed 's/^\/\([^\/]*\).*/\1/'); do echo $pref$f; done) ! $(echo ${pref}**/CVS(:h) | sed 's/CVS//')) } #------------------------------------------------------------------------------ # RedHat Linux rpm utility --- 439,448 ---- pref= fi [[ -n "$pref" && "$pref" != */ ]] && pref=$pref/ ! reply=($(for f in \ ! "${${${(f@)$({<${pref}CVS/Entries} 2>/dev/null)}#/}%%/*}" \ ! do echo $pref$f; done) ! ${pref}*/**/CVS(:h)) } #------------------------------------------------------------------------------ # RedHat Linux rpm utility -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"