Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!ux1.cso.uiuc.edu!osiris.cso.uiuc.edu!funk From: funk@osiris.cso.uiuc.edu Newsgroups: comp.unix.questions Subject: Re: Strangeness in shell Message-ID: <9700009@osiris.cso.uiuc.edu> Date: 22 Jul 89 09:17:00 GMT References: <432@mccc.UUCP> Lines: 37 Nf-ID: #R:mccc.UUCP:432:osiris.cso.uiuc.edu:9700009:000:1612 Nf-From: osiris.cso.uiuc.edu!funk Jul 22 04:17:00 1989 fawcett@steven.com writes: >pjh@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@osiris.cso.uiuc.edu | |ACSEH, 21st TAACOM __________________________________________________| |Kaiserslautern, W. Germany | Any resemblance between me and reality | |(guesting on osiris) | is strictly coincidental | -------------------------------------------------------------------------------