From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28959 invoked from network); 27 Apr 2001 17:32:16 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Apr 2001 17:32:16 -0000 Received: (qmail 3451 invoked by alias); 27 Apr 2001 17:31:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14139 Received: (qmail 3380 invoked from network); 27 Apr 2001 17:31:53 -0000 To: zsh-workers@sunsite.auc.dk Subject: order of processing in brace expansion Reply-to: apoindex@aoc.nrao.edu From: Allan Poindexter Date: 27 Apr 2001 11:31:48 -0600 Message-ID: X-Mailer: Gnus v5.6.45/XEmacs 21.1 - "Acadia" Consider the following: pts/11 10:37 208%setopt braceccl cato:/export/home/cato/apoindex pts/11 10:38 209%foo=b,c cato:/export/home/cato/apoindex pts/11 10:38 210%echo a{$foo}d cato:/export/home/cato/apoindex a,d abd acd pts/11 10:38 211%echo a{b,c}d cato:/export/home/cato/apoindex abd acd pts/11 10:38 212%unsetopt braceccl cato:/export/home/cato/apoindex pts/11 10:38 213%echo a{$foo}d cato:/export/home/cato/apoindex a{b,c}d According to info: Expansion is done in the above specified order in five steps. The first is "history expansion" which is only performed in interactive shells. The next step is "alias expansion" which is done right before the command line is parsed. They are followed by "process substitution", "parameter expansion", "command substitution", "arithmetic expansion", and "brace expansion" which are performed in one step in left-to-right fashion. After these expansions, all unquoted occurrences of the characters `\', `'', and `"' are removed and the result is subjected to "filename expansion" followed by "filename generation". Since brace expansion has syntactic markers at two points there is some ambiguity about where it would fall in the left to right processing but it seems that neither choice should cause the actual behavior seen. If brace expansion is considered to occur at the opening brace then I would expect: %setopt braceccl %echo a{$foo}d a$d afd aod %unsetopt braceccl %echo a{$foo}d ab,cd in the above example since the brace expansion would occur before $foo was parameter expanded. If brace expansion is considered to occur at the closing brace then I would expect: %echo a{$foo}d abd acd since parameter expansion would occur first. (The setting of brace_ccl would be unimportant in this case.) What actually occurs seems to be that it is decided what kind of brace expansion is needed at the opening brace but the brace expansion is actually done (consistent with the decision of type made earlier) at the closing brace. My personal preference would be for brace expansion to occur entirely at the closing brace since that seems to me to be the most useful definition. Perhaps others have a different view. Can anyone shed any light on what I might be overlooking here? /-\ |_ |_ /-\ |\|