Bruno Haible <br...@clisp.org> wrote: > > If you use a modern printf(1) implementation (as available in "bosh"), you > > could even use: > > > > printf "$(gettext 'Hello World %2$d %1$d')\\n" 1 2 > > > > to be able to control the order of the output of arguments in a way that is > > specific to the target language. ... > > > BTW: this extension is also available in /bin/printf on OpenSolaris and > > FreeBSD. > > Yes, it would be good to have this %n$d syntax in 'printf' standardized > by POSIX [1]. This way of allowing argument reordering by translators is > supported by many programming languages. It would be good to have it > portably supported in shell scripts as well.
Most platforms support it anyway. It has been introduced in 1988 for ksh88 and /bin/printf on SVr4/Solaris - but only usable for string parameters as: printf "Hello World %2$s %1$s\\n" 1 2 This simple (string only) variant is supported on: /bin/printf on Oracle Solaris but limited to 20 arguments only Most likely (as it is the same source) on HP-UX and AIX as well. ksh88 anywhere mksh a ksh88 clone The full version that supports any type of format strings (including %d, ...) is supported by: /bin/printf on OpenSolaris (SchilliX and Illlumos) and on FreeBSD ksh93 anywhere bosh anywhere zsh anywhere Not usable is this feature only with: /bin/printf on Linux, ... bash anywhere dash anywhere yash anywhere Jörg -- EMail:jo...@schily.net (home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'