[geos-devel] [GEOS] #1015: Update geos-config tool for consistency

Mike Taves mwtoews at gmail.com
Tue Feb 18 01:16:38 PST 2020


On Tue, 18 Feb 2020 at 20:22, Sandro Santilli <strk at kbt.io> wrote:
> > properly escape a path. While I see there is also /usr/bin/printf I'm
> > not sure how common or standard this tool is (my tests with /bin/sh
> > didn't go well, so I opted to switch to Bash for reliability).
>
> GNU coreutils "printf" works fine here:
>
>   [strk at liz:~] /usr/bin/printf "%q\n" "space 'quote' and \"doublequote\""
>   'space '\''quote'\'' and "doublequote"'
>   [strk at liz:~] /usr/bin/printf  --version | head -1
>   printf (GNU coreutils) 8.28

The printf function in Bash has supported the %q directive for much longer
https://stackoverflow.com/a/26069697
https://web.archive.org/web/20031119043100/http://www.gnu.org/software/bash/manual/bashref.html

whereas the %q directive for /usr/bin/printf was introduced a few
years ago, and seems to produce a different output, for example having
a single quotation mark on either end of the above example. Bash's
printf does not add single quotation marks to the output, as it is in
a format that can be reused as shell input.

In short: I can't easily get the same escaped output using #!/bin/sh


More information about the geos-devel mailing list