[Buildroot] [RFC PATCH 5/9] support/scripts: add create-relocation-script for toolchain relocation
Arnout Vandecappelle
arnout at mind.be
Fri Mar 17 22:09:34 UTC 2017
On 17-03-17 18:15, Wolfgang Grandegger wrote:
> Am 17.03.2017 um 16:50 schrieb Arnout Vandecappelle:
>>
>>
>> On 17-03-17 08:10, Wolfgang Grandegger wrote:
[snip]
> # Replace the old path with the new one in all text files
> while read FILE ; do
> if file -b --mime-type "${FILE}" | grep -q '^text/' && [ "${FILE}" != "./usr/share/buildroot/sdk-location" ]
> then
> sed -i s,"${OLDPATH}","${NEWPATH}",g "${FILE}"
> fi;
> done < <(grep -lr "${OLDPATH}" .)
>
> As grep -rl is very fast; I now use the following construct handling file with names
> with space corectly. BTW, is ',' is also a valid name character. Are all characters
> allowed for file names? Is there a known trick?
All characters except / and \0 are allowed in file names. Look at [1] for a
long rant (and a number of good approaches) about this subject. Note that our
scripts don't have to be portable, so we can use e.g. find -print0. But your
proposal is pretty good, just needs 'read -r' insteade.
So OLDPATH or NEWPATH could indeed contain a comma. You can check for that at
the beginning and error out.
Regards,
Arnout
[1] https://www.dwheeler.com/essays/filenames-in-shell.html
[snip]
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
More information about the buildroot
mailing list