Fixing bash script bogosity - help?

pgf at laptop.org pgf at laptop.org
Tue Apr 28 09:09:19 EDT 2009


bert wrote:
 > 
 > On 28.04.2009, at 14:27, pgf at laptop.org wrote:
 > 
 > > bert wrote:
 > >>
 > >> On 28.04.2009, at 13:37, Martin Langhoff wrote:
 > >>
 > >>> On Tue, Apr 28, 2009 at 1:19 PM, Ignacio Vazquez-Abrams
 > >>> <ivazqueznet at gmail.com> wrote:
 > >>>> Ah, I see now.
 > >>>>
 > >>>> Try this:
 > >>>>
 > >>>> bash -c 'touch "$@"' "${CMD[@]}"
 > >>>
 > >>> Riiight, that works better... but
 > >>>
 > >>>> Or in the case of the full script:
 > >>>>
 > >>>> bash -c "$ERL"' "$@"' "${ERL_COMMAND[@]}"
 > >>>
 > >>> ...it doesn't work for runuser -- which is the real target. Runuser
 > >>> looks at the added params after -c and tries to parse them. There
 > >>> doesn't seem to be any support for passing parameters.
 > >>>
 > >>> hmmmmm.
 > >>
 > >> Maybe you should use su directly instead of runuser?
 > >
 > > won't that have the same problem?  it still wants a command
 > > passed via a -c STRING convention.
 > >
 > > i think this is somewhat intractable, and any time spent on it
 > > would be better spent creating a patch to runuser that lets it
 > > take its command as strace does, or as xterm does with -e, which
 > > avoids the vector->string->vector translations which are the real
 > > issue.
 > 
 > 
 > No, su passes all arguments after -c to the program you specify.

can you give an example?

    $ su root -c /bin/echo one two three
    Password: 

    $ su root -c '/bin/echo one two three'
    Password: 
    one two three
    $ 

paul
=---------------------
 paul fox, pgf at laptop.org



More information about the Devel mailing list