On Tue, 18 Feb 2020 at 20:22, Sandro Santilli <s...@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@liz:~] /usr/bin/printf "%q\n" "space 'quote' and \"doublequote\""
>   'space '\''quote'\'' and "doublequote"'
>   [strk@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
_______________________________________________
geos-devel mailing list
geos-devel@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/geos-devel

Reply via email to