From: Stephen W. <st...@ke...> - 2006-07-15 14:32:52
|
"Thomas Leonard" <ta...@gm...> wrote: > On 7/15/06, Stephen Watson <st...@ke...> wrote: > > Jim Ramsay <i....@ji...> wrote: > > > > > These patches allow you to specify multi-word commands for the custom > > > mount, unmount (and eject) commands, and then appends the appropriate > > > path to the list. For example, if you enter "sudo mount -o ro" in the > > > custom mount option and try to mount /mnt/cdrom, it will end up running > > > "sudo mount -o ro /mnt/cdrom". > [...] > > I've changed this to use "sh -c <cmd>" so sh can do the parsing of the > > command line, rather than just splitting on spaces. I also allowed $1 to > > appear anywhere in the command which will be substituted with the path. > > Thanks Stephen, > > The new build_command_with_path logic looks similar that in > run_with_argument(). We should only use one system, although I'm not > sure which is better... > > (the check for '\' looks suspicious though... what happens if there is > a '\' at the end of the string?) It goes boom. Fixed it. > In summary, we seem to have three methods for building/running commands: > > - g_shell_parse_argv (splits on spaces, but no other substitutions) > - build_command_with_path (replaces first non-escaped $1) > - run_with_argument (lets shell handle substitution completely) I would favour replacing build_command_with_path with build_command_with_arguments which uses run_with_arguments trick of sh -c cmd sh args... and have it return a GPtrArray. Then we re-write run_with_argument, mount/unmount/eject and probably others to use it as a back end. -- Stephen Watson http://www.kerofin.demon.co.uk/ If you read this on a mailing list, send any reply back to the list and not to me. Not even CC. My bleeding heart does not extend to charity |