On Fri, Oct 22, 2010 at 08:34, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote: > Ãvar ArnfjÃrà Bjarmason wrote: > >>     gettext () { >>       printf "%s" "$1" >>     } >> >>     eval_gettext () { >>       gettext_eval="printf '%s' \"$1\"" >>       printf "%s" "`eval \"$gettext_eval\"`" >>     } > > This looks wrong. ÂConsider a simplified example: > >    Âeval_gettext 'foo "bar baz"' > > Now eval_gettext is supposed to just interpolate $variable > substitutions, right? ÂIn particular, the quotation marks > ought to be preserved. > > But instead, what gets evaluated is: > >    Âprintf '%s' "foo "bar baz"" > > which splits as > >    Âprintf '%s' 'foo bar' 'baz' > > which is equivalent to > >    Âprintf '%s' 'foo bar' >    Âprintf '%s' 'baz' > > with output > >    Âfoo barbaz Indeed. It's a bug. > Maybe something like this would do it? > >    Âgettext_eval=$( >        Âprintf '%s\n' "$1" | >        Âsed ' >            Âs/[`\\"]/\\&/g >            Â1 s/^/printf "%s" "/ >            Â$ s/$/"/ >        Â' >    Â) && >    Âeval "$gettext_eval" That prints: foo "bar baz" (with double quotes) But what we want is: foo bar baz But what we're getting is: foo barbaz Have I got that right, sorry, not thinking clearly right now :) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html