Ran into an issue when running the following command in a fish shell:
❯ printf '%q\n' 'André Previn & London Symphony Orchestra'
%q: invalid conversion specification
I hadn't realized at first that fish actually has their own custom printf function that behaves in largely the same way as the GNU coreutils printf function, but does not support the q directive like GNU coreutils printf does.
fish-shell docs:
https://fishshell.com/docs/current/cmds/printf.html#format-specifiers
GNU coreutils printf docs:
https://www.gnu.org/software/coreutils/manual/html_node/printf-invocation.html#printf-invocation
Is there a way to tell fish-shell that I want it to use the GNU coreutils printf function instead of their customized printf function?
[Edit 1]: I hadn't realized that MacOS has it's own BSD-derived builtins that it uses, not the GNU coreutils builtins. Still am able to use the q option in zsh, but not in fish when running the following commands:
# in zsh
❯ printf '%q\n' 'test'
test
# fish, run in a zsh shell
❯ builtin printf '%q\n' 'test'
%q: invalid conversion specification
❯ command printf '%q\n' 'test'
printf: illegal format character q


printfis a builtin, so I'm not sure there is an absolute path I can reference - I think it's prebaked into the shell, in my casezshprintffrom your zsh? In this case, create a zsh wrapper, which just invokes its builtin printf and passes to it all its parameters.gprintfutility which is all you need to solve your issue. See my answer below.gprintffor this purpose. Thanks again.