help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Simple echo is printing the wrong value


From: Bill Gradwohl
Subject: Re: [Help-bash] Simple echo is printing the wrong value
Date: Wed, 4 Apr 2012 21:24:44 -0600

On Wed, Apr 4, 2012 at 2:03 PM, Chet Ramey <address@hidden> wrote:

I cannot imagine any circumstances under which you would want to take
a valid, existing filename, and create from it an indeterminate number
of separate words.  Even if you wanted to act on the entire set of files
in the directory at the same time.


This is testing code.

file='*'
echo $file          yields a long list of file names, but
case $file in       doesn't.

It's the difference I was trying to highlight and figure out why * does different things under different circumstances.

Greg called it magic. To me it's just confusing. Expanding * in the case construct doesn't make sense, I agree, but I would issue an error message instead. If * expands in one context, it should expand in all contexts, and in those where it doesn't make sense, do the equivalent of a compile error, bad substitution, whatever.

That's what makes sense to me. I realize that's impossible with bash at this late stage of the game with people relying on how it functions as is, but its these idiosyncrasies that I keep bumping in to.

IFS= read                works

set -- '' '' ''
IFS= echo "${*}"         doesn't

Yes - I know its a parser issue, but its still unexpected.

I'm trying to figure it out.

--
Bill Gradwohl


reply via email to

[Prev in Thread] Current Thread [Next in Thread]