Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks Stephane. Oddly enough, the construction printf '%s\n' "$var" works for me on the command line (zsh 5.0.2, i.e. the latest), but not inside a function (see my update in the OP). Why? Commented Mar 29, 2013 at 1:09
  • 1
    It's printf '%s\n', not printf '$s\n' you want. Note that you need to quote variables in other shells than zsh ("$1", not $1) and the standard function definition syntax is foo() { ...; }, though any shell but bash allow foo() any-command, and function foo { .... } is the ksh syntax. Commented Mar 29, 2013 at 8:00
  • @Marcus, that's an answer to a different question. Commented Apr 29, 2019 at 16:12
  • Why does this not work: printf 'C:\foo\bar.xml'.This works: echo -E 'C:\foo\bar.xml' - Why do you put the dash in echo -E -? Commented Jan 26, 2021 at 18:52