From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20340 invoked from network); 9 Aug 1998 07:15:54 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Aug 1998 07:15:54 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id CAA26312; Sun, 9 Aug 1998 02:52:21 -0400 (EDT) Resent-Date: Sun, 9 Aug 1998 02:51:58 -0400 (EDT) Message-ID: <19980809025636.18149@astaroth.nit.gwu.edu> Date: Sun, 9 Aug 1998 02:56:36 -0400 From: Sweth Chandramouli To: ZSH Users Subject: sorting/uniq-ing an array? Mail-Followup-To: ZSH Users Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89 Resent-Message-ID: <"i_zch1.0.kQ6.ESKpr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1709 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu while playing around with zsh completion, i noticed that the ports variable set in the comctl-examples file doesn't distinguish between tcp and udp services in /etc/services, resulting in a non-unique array (e.g. multiple instances of "echo"). i've come up with a way to remove redundant entries from an array (the appropriate part of my .zshrc is at the end of this message), but it's very slow--on a single-user ultrasparc/30, it adds about two seconds to my login time. is there a faster way to do this? for some uses, it's okay-- i've got a function called addpath, for example, that uses this sort of looping to scan $PATH to see if the argument passed to addpath is already in it, and iff it isn't, adds it, and a second or two to process that function (usually almost unnoticeable, actually, since $PATH is so much shorter than $ports) doesn't seem strange. as an addition to the login process, however, it seems like it takes an eternity. i was thinking of creating a file that stored the array, and on login, first populate $ports with the contents of that file, and then spawned a bg process to do the parsing from /etc/services, write the output out to the file, and then repopulate $ports. any suggestions on how to do that, or of other (quicker) ways to do the parsing of the array? (as always, of course, comments on style are also appreciated. i'm fairly certain that i still don't understand when ${= is needed and when it isn't, so i just tend to use it everywhere that splitting might be needed. did i do it right here?) tia, sweth. --- begin quoted text --- #### ports is made unique in an ugly way. is this fixable? portnames=("${${${(f)$( / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) *