Sujet : Re: Long filenames in DOS/Windows and Unix/Linux
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.unix.programmerDate : 05. Sep 2024, 10:29:14
Autres entêtes
Message-ID : <ygay146mot1.fsf@akutech.de>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* Richard Kettlewell <
invalid@invalid.invalid>
| Keith Thompson <Keith.S.Thompson+
u@gmail.com> writes:
| > [...] For example, I might type something like:
| >
| > for file in * ; do cp -p $file $file.bak ; done
>
| That’s the heart of the matter. Field splitting happens after parameter
| expansion.
Only sometimes it doesn't :-)
$ foo="foo bar"
$ bar=$foo
No problem with the space in the expanded value here!
$ echo $bar
foo bar
but of course:
ls $bar
ls: cannot access 'foo': No such file or directory
ls: cannot access 'bar': No such file or directory
It's documented in bash(1):
PARAMETERS
[...]
A variable may be assigned to by a statement of the form
name=[value]
[...] Word splitting is not performed, with the exception of
"$@" as explained below under Special Parameters.
but I find it confusing nevertheless.
R'