[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: No support for spaces in for loop
From: |
Chris F.A. Johnson |
Subject: |
Re: No support for spaces in for loop |
Date: |
Tue, 18 Aug 2015 18:55:41 -0400 (EDT) |
User-agent: |
Alpine 2.10 (DEB 1266 2009-07-14) |
On Wed, 19 Aug 2015, Yan Pashkovsky wrote:
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2
-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -Wall
uname output: Linux mint-desktop 3.16.0-43-generic #58~14.04.1-Ubuntu SMP Mon
Jun 22 10:21:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3
Patch Level: 11
Release Status: release
Description:
"for file in *" doesn't correctly parse files containing spaces in
their filenames. For example file "an image of duck.jpg" will be interpreted
as 4 files "an" "image" "of" "duck.jpg"
Yes, it does.
Your problem is (probably, since you didn't include an example) that
you omitted quotes around its expansion, e.g.:
printf '%s\n' $file
That should be:
printf '%s\n' "$file"
Repeat-By:
--
Chris F.A. Johnson, <http://cfajohnson.com>