extfs: rpm: use printf instead of echo, to calculate DESCRIPTION length.
commit95f2f1435790d372d105f25b70ec765e073d87d3
authorMooffie <mooffie@gmail.com>
Wed, 8 Mar 2017 15:47:24 +0000 (8 17:47 +0200)
committerMooffie <mooffie@gmail.com>
Wed, 8 Mar 2017 23:03:41 +0000 (9 01:03 +0200)
treea944cc79b49cb03cefac084bfb8fcc62cc3be76b
parente2f5034303ab4ea06a86c577b863d6c39946c884
extfs: rpm: use printf instead of echo, to calculate DESCRIPTION length.

Out test input intentionally contains weird characters in the DESCRIPTION field
(see the file 'test.spec'[1]).

It turns out that backslash sequences, as in our DESCRIPTION field, are
processed by the 'echo' command in some shells (i.e., Dash). In other words,
'echo' can't be used to print arbitrary data verbatim. Indeed, the standard
says[2] that "if any of the operands contain a <backslash> character, the
results are implementation-defined". You can see the problem by running:

    $ echo "one \\a two"

under both Bash and Dash: you'll get different results.

The solution: we replace 'echo' with 'printf'.

[1] https://midnight-commander.org/browser/tests/src/vfs/extfs/helpers-list/misc/rpm/test.spec#L34
[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

Signed-off-by: Mooffie <mooffie@gmail.com>
src/vfs/extfs/helpers/rpm