mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-13 06:49:22 +03:00
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>
This commit is contained in:
parent
e2f5034303
commit
95f2f14357
@ -224,7 +224,7 @@ mcrpmfs_list ()
|
||||
DATE=`mcrpmfs_getRawOneTag "%{BUILDTIME:date}\n" | cut -c 5-11,21-24`
|
||||
PAYLOAD=`mcrpmfs_getRawOneTag "%{PAYLOADFORMAT}\n" | sed s/ustar/tar/`
|
||||
|
||||
HEADERSIZE=`echo "$DESC" | wc -c`
|
||||
HEADERSIZE=`printf '%s\n' "$DESC" | wc -c` # 'echo' can't be used for arbitrary data (see commit message).
|
||||
printf '%s %s %s HEADER\n' "${FILEPREF}" "${HEADERSIZE}" "${DATE}"
|
||||
echo "-r-xr-xr-x 1 root root 39 $DATE INSTALL"
|
||||
case "${rpm_filename}" in
|
||||
|
Loading…
Reference in New Issue
Block a user