martymac / fpart

Sort files and pack them into partitions
https://www.fpart.org/
BSD 2-Clause "Simplified" License
230 stars 39 forks source link

fpsync: Fix `tool_get_fpart_mode_opts` so that we can pass `-E` to `fpart` #34

Closed Licht-T closed 3 years ago

Licht-T commented 3 years ago

When "Directory mode", fpsync will pass -E to fpart but actually does not. This is caused by the behavior of echo: -E is treated as an option for echo itself. This PR fixes the issue.

$ echo "-E"

$
martymac commented 3 years ago

Hello Licht,

Good catch, thanks !

What about using : printf "%s\n" "-E" instead ?

The Opengroup says : "It is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) and escape sequences are omitted." (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html)

Could you update the PR ?

Licht-T commented 3 years ago

@martymac Hello Ganael, thank you for the review!

Just before, I also found that echo -e option did not work on some shell, and Autoconf used printf instead. https://translate.google.com/translate?sl=ja&tl=en&u=https://mattintosh.hatenablog.com/entry/2013/12/11/201503

I have just updated my PR so that we use printf!

Licht-T commented 3 years ago

NOTE: It may be better that we replace other echo's by the Autoconf style in another PR.

as_echo='printf %s\n'
as_echo_n='printf %s'

$as_echo "foobar"
$as_echo_n "foobar"
martymac commented 3 years ago

@Licht-T,

Yes, I'll take a look at other calls to echo in a near future. Thanks for your patch !