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*

3
  • What is your operating system? Is your /bin/sh bash or is it dash? Or something else? Commented Nov 16 at 12:58
  • If you want to do stuff combining sed, shell, function calls, etc then do yourself a favour and just use perl. It'll be easier, far more capable, faster, and you won't end up getting lost in a maze of twisty little quotation marks. Simple example: echo bar | perl -pe 'BEGIN{sub myfoo {my $str = shift; return "foo $str"}}; s/.*/myfoo $&/e' (sure, this trivial example doesn't need the /e modifier OR a function, but it does illustrate what's possible and how much easier it is than doing it in shell). people try to do too much in shell, a language that makes easy things needlessly difficult. Commented Nov 16 at 14:35
  • What is your /bin/sh? Is it perhaps a symlink to bash? Does this work if you run export -f printf_stdin before your first command? Commented Nov 17 at 16:33