On Tue, Apr 05, 2011 at 04:44:27AM -0700, Philip Guenther wrote:
> On Tue, Apr 5, 2011 at 4:07 AM, Piotr Sikora <[email protected]> wrote:
> > $daemon_flags are sanitized using echo and tr, but the input isn't quoted,
> > which makes it indistinguishable from echo's options. Effect of this is that
> > when $daemon_flags starts with "-n" then this argument is lost in the
> > process.
> ...
> > -daemon_flags=$(echo ${daemon_flags} | tr -s "[:space:]")
> > +daemon_flags=$(echo "${daemon_flags}" | tr -s "[:space:]")
>
> Insufficient for the daemon_flags=-n case. To be completely safe, use printf:
>
> daemon_flags=$(printf '%s\n' "${daemon_flags}" | tr -s "[:space:]")
>
>
> Philip Guenther
Yep, I like this better than my solition.
-Otto