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 BAA09387 for ; Fri, 7 Jun 1996 01:03:12 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA20288; Thu, 6 Jun 1996 10:54:55 -0400 (EDT) Resent-Date: Thu, 6 Jun 1996 10:54:55 -0400 (EDT) From: Zefram Message-Id: <6465.199606061454@downwind.dcs.warwick.ac.uk> Subject: Globbing in redirections To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Thu, 6 Jun 1996 15:54:30 +0100 (BST) X-Patch: 106 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]7618.10 X-US-Congress: Moronic fuckers MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"gaGWK2.0.wy4._4ljn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1276 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- This patch makes redirection behave a little more like ksh. It disables globbing on filenames in redirections, but only when multios are disabled. (Globbed redirections are a very useful way to generate multios.) Note that behaviour is still not exactly like ksh, as brace expansion is still done. But ksh seems to treat brace expansion as part of globbing: compare "echo ~{root,nobody}" in the two shells. (KSH_BRACES, anyone?) This patch as written relies on my recent large options patch, that changed the NO_MULTIOS option into MULTIOS. If you haven't applied that, change "isset(MULTIOS)" to "unset(NOMULTIOS)". -zefram Index: Doc/zshmisc.man *** zshmisc.man 1996/06/06 01:45:20 1.5 --- zshmisc.man 1996/06/06 02:05:26 *************** *** 512,517 **** --- 512,532 ---- .PP writes the date to the file "foo", and also pipes it to cat. .PP + If the + .B MULTIOS + option is set, the word after a redirection operator is also subjected + to filename generation (globbing). Thus + .RS + .PP + .B : > * + .RE + .PP + will truncate all files in the current directory, + assuming there's at least one. + (Without the + .B MULTIOS + option, it would create an empty file called "*".) + .PP If the user tries to open a file descriptor for reading more than once, the shell opens the file descriptor as a pipe to a process that copies all the specified inputs to its output in the order Index: Src/glob.c *** glob.c 1996/06/06 01:45:30 1.8 --- glob.c 1996/06/06 02:06:51 *************** *** 862,868 **** addlinknode(fake, fn->name); /* ...which undergoes all the usual shell expansions. */ prefork(fake, 0); ! if (!errflag) globlist(fake); if (errflag) return 0; --- 862,869 ---- addlinknode(fake, fn->name); /* ...which undergoes all the usual shell expansions. */ prefork(fake, 0); ! /* Globbing is only done for multios. */ ! if (!errflag && isset(MULTIOS)) globlist(fake); if (errflag) return 0; -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMbY/BHD/+HJTpU/hAQFX1AP8DZcutSWVln2VufviHDskuXPr5MbP5wTi S2YhTOYPCQ/JCfh2BeQTZXw/k/TNM5vSQC7EawulBEOB42ClMQJdo5IRrReh0HUP tQNptWP7YVm879YKHp26ka8vl2tmrcqC0J0M3mEqAEFQ124AMRvsJ4cG1bOV1vDz BiZusin6gj4= =kDm+ -----END PGP SIGNATURE-----