From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Tolpin Message-Id: <200403190757.i2J7vUIO097549@adat.davidashen.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] ls, rc question -- proposed change to rc/glob.c In-Reply-To: <20040319070100.GA7900@epaphras.cnm-vra.com> Date: Fri, 19 Mar 2004 11:57:30 +0400 Topicbox-Message-UUID: 37caa500-eacd-11e9-9e20-41e7f4b1d025 > > Do you think that rc globbing returning as many identical words > > as there are directory entries with the same name is in any > > way useful too? > > Of course! Let's suppose you have a multipage document > that you want to print multiple copies of, but you want > all the copies of a single page to print together. Well, Since I don't have a printer, here is a proposed change to rc/glob.c cpu% diff /sys/src/cmd/rc/glob.c glob.c 31c31 < word *a; --- > word *a, *b; 37c37,47 < for(a = left,n = 0;a!=right;a = a->next,n++) a->word = list[n]; --- > for(a = left,n = 0;a!=right;n++){ > if(a->next!=right && globcmp(list+n,list+n+1)==0){ > b = a->next; > a->next = b->next; > efree((char *)list[n]); > efree((char *)b); > }else{ > a->word = list[n]; > a = a->next; > } > } Since rc sorts results of globbing expansion, it makes perfect sense to only keep only one occurence of each path name. It bring rc in synchronization with the manual; besides, repeated names cannot be used for access to the files they are generated for so they should be omitted. I am not supplying it as a patch because I actually want to know opinions whether it makes sense. David Tolpin