Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Question about handling filenames with "illegal" characters...
Date: Thu, 16 Apr 2020 15:30:09
Message-Id: CAGfcS_ntMzP5Xz+MsNw6w_2P0vV+HN3cu_gEnuJx30jDSMvedw@mail.gmail.com
In Reply to: Re: [gentoo-user] Question about handling filenames with "illegal" characters... by Neil Bothwick
1 On Thu, Apr 16, 2020 at 11:19 AM Neil Bothwick <neil@××××××××××.uk> wrote:
2 >
3 > On Thu, 16 Apr 2020 17:15:45 +0200, tuxic@××××××.de wrote:
4 >
5 > > a loop like this
6 > >
7 > > for fn in asd* ; do
8 > > do_something $fn
9 > > done
10 > >
11 > > fails, when a file is named like this:
12 > >
13 > > List of OSses allowing spaces in filenames.txt
14 > >
15 >
16 > do_something "$fn"
17 >
18
19 That, or use ${fn} - that might be more resistant to quotes in
20 filenames though I haven't looked closely into that.
21
22 If you look at most ebuilds they're full of quoted or braced variables
23 for exactly this reason. If you want to stick spaces in your
24 directory paths that is your mess to deal with, but Gentoo won't
25 break.
26
27 On a side note, if you have a directory full of crufty filenames the
28 detox program is very useful for cleaning them up. Of course, that is
29 invasive and you probably don't want to rely on that in your script.
30
31 --
32 Rich

Replies