[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] for File in Folder_Variable_Name Expansion
From: |
Chris Down |
Subject: |
Re: [Help-bash] for File in Folder_Variable_Name Expansion |
Date: |
Mon, 16 Dec 2013 23:06:59 +0800 |
User-agent: |
Mutt/1.5.22 (2013-10-16) |
On 2013-12-16 04:33:58 -0900, Roger wrote:
> This was the crux of my problem here. Although the whitespace/space within
> the
> folder (or filename, or path) was an initial issue until I used a wildcard
> (or
> globbing, or "*", or "?") for substitution of the whitespace.
>
> This main issue of "for FILE in /PATH/*.jpg" was really difficult, as I
> always
> prefer using global variables instead of statically assigned data. (As most
> others likely do too.) I was thinking this should just work when written as
> "for FILE in /PATH/*.jpg" as it appeared syntactically correct compared to
> other variable usage or other variable assignments. (ie. printf
> "${HOME}/file.jpg")
The reason is the quoting, nothing else. When quoted, "?" has no special
meaning.
> About the only question remaining, is why some bash commands (or functions)
> do
> not uniformly accept variable expansion similar to using within printf or
> echo.
> (ie. printf "${HOME}/file.jpg") But suspect every command handles expansion
> based on each commands programmed method of handling a variable expansion.
Bash is the one doing variable expansion, not the commands, so I'm not
sure what you mean. If you do foo "$bar", and bar is "baz", then "foo"
only ever sees "baz", it never knows that you passed a variable in the
first place.
Can you give an example of why you think this?
> Looking back over the Bash Manual, I see printf or echo listed under the
> "SHELL
> BUILTIN COMMANDS" category, and the "for" command categorized under "SHELL
> GRAMMAR > Pipelines". As such, each category of commands, handles expansion
> differently?
No, they don't; they handle expansion in the same way (in that they
don't, bash does it separately). If you could give a minimal example of
what made you think this, that would be helpful.
pgpINX5f5uNXM.pgp
Description: PGP signature
Re: [Help-bash] for File in Folder_Variable_Name Expansion, Roger, 2013/12/16