** Reply to message from Andreas Kahari <[EMAIL PROTECTED]> on Wed, 3 Aug 2005 13:55:59 +0100
>See sh(1), under "Command execution": > >[...] Just to confuse things, if the posix option is turned off (see >the set command below), some special commands are very special in that >no field splitting, file globbing, nor tilde expansion is performed on >arguments that look like assignments. An interesting idea, but it doesn't fix the problem -- at least, adding a couple of 'set -o posix' lines (as shown below) didn't change the results. Actually, I wouldn't expect this to have an effect since the 'simple' match which does work also requires file globbing in the same context... Modified script (result unchanged): #! /bin/sh function DoIt { set -o posix set -A files $1 echo "match = '$1'" typeset -i idx idx=0 while [ idx -lt ${#files[*]} ] ; do echo "files[$idx] = '${files[$idx]}'" idx=idx+1 done return 0 } set -o posix DoIt "/var/log/pf/103790/*" echo "" DoIt "/var/log/pf/103790/+([a-zA-Z])+([0-9]).@(in|out).@(block|pass).@(destIP|destPort|srcIP)" Thanks, Dave >On 03/08/05, Dave Anderson <[EMAIL PROTECTED]> wrote: >> Something's screwy here, using the 'set -A' command in /bin/sh on >> 3.7-release. AFAICT the complicated file-match expression should (in >> this case) produce the same results as the simple one, but it doesn't >> seem to match at all when used in this script -- but does produce the >> expected result when cut-and-pasted to a command line. >> >> Any constructive comments would be greatly appreciated. >> >> Dave >> >> The results: >> >> match = '/var/log/pf/103790/*' >> files[0] = '/var/log/pf/103790/ne3.in.block.destIP' >> files[1] = '/var/log/pf/103790/ne3.in.block.destPort' >> files[2] = '/var/log/pf/103790/ne3.in.block.srcIP' >> >> match = >> '/var/log/pf/103790/+([a-zA-Z])+([0-9]).@(in|out).@(block|pass).@(destIP|destPort|srcIP)' >> files[0] = >> '/var/log/pf/103790/+([a-zA-Z])+([0-9]).@(in|out).@(block|pass).@(destIP|destPort|srcIP)' >> >> The script: >> >> #! /bin/sh >> function DoIt { >> set -A files $1 >> echo "match = '$1'" >> typeset -i idx >> idx=0 >> while [ idx -lt ${#files[*]} ] ; do >> echo "files[$idx] = '${files[$idx]}'" >> idx=idx+1 >> done >> return 0 >> } >> DoIt "/var/log/pf/103790/*" >> echo "" >> DoIt >> "/var/log/pf/103790/+([a-zA-Z])+([0-9]).@(in|out).@(block|pass).@(destIP|destPort|srcIP)" -- Dave Anderson <[EMAIL PROTECTED]>