Strangeness in shell

funk at osiris.cso.uiuc.edu funk at osiris.cso.uiuc.edu
Sat Jul 22 19:17:00 AEST 1989


fawcett at steven.com writes:
>pjh at mcc.UUCP writes:
>>If I assign a shell variable a value that contains an asterisk, the
>>shell behaves strangely if there is a space adjacent to said asterisk. 
>>For example,
>>	x='*z'
>>	echo ${x}
>>produces
>>	*z
>>but 
>>	x='* z'
>>	echo ${x}
>>produces
>>	(a list of all the files in the current directory) z
>>	
>>What does the space have to do with this?

>The problem here is that the "set" of x stripped off the single quotes.
>This left only the *, which matches all occourances of one or more
>characters.  Why it looked in your directory for these files I don't know.
>The fact that the *z echoed simply means that you don't have any files in
>your directory that end in the letter z.
>
 Ummm... I had always learned (obviously flawed) that the single quotes 
prevented expansion of ANYTHING....
Even if this is not the case, why does it behave differently in the two cases?
If you have no files ending in  z  , then why does it not return a null 
string for the '*z' version ?   What is its algoithm for determining when it is going to be literal and when it is going to expand???


-------------------------------------------------------------------------------
|        Bruce Funk                         INTERNET: funk at osiris.cso.uiuc.edu |
|ACSEH, 21st TAACOM          __________________________________________________|
|Kaiserslautern, W. Germany  | Any resemblance between me and reality          |
|(guesting on osiris)        | is strictly coincidental                        |
-------------------------------------------------------------------------------



More information about the Comp.unix.questions mailing list