On Sun, Dec 25, 2011 at 01:49:05PM -0500, Filipus Klutiero wrote: >>>> But that matters for interoperability. The point of this section is to be >>>> able to issue the command: >>>> x-terminal-emulator -e vi 'some file' >>>> and know that it works. If you don't use exec, it won't. >>> I don't see why exec would be necessary. As long as the emulator >>> supports being given any simple command as its -e option, such commands >>> should work. >> x-terminal-emulator -e vi 'some file' is required to edit the single file >> named 'some file' (with a space), not two files, one named some and one >> named file, which is the behavior you get if you pass the command to the >> shell by using something like system(). > > It depends what command is given to system(). The command needs to be > well-formed (quoted and escaped) to work and work as expected.
Generally for things like this, developers don't use system().
> By the way, the command you give makes me realize that current policy
> not only specifies what values of -e should be supported, but how -e
> should be given ("interpreting the entirety of the rest of the command
> line as [...].") If we want
>
> x-terminal-emulator -e vi 'some file'
For the example given, a C program will see argv[] with something like
argv[0] = "x-terminal-emulator"
argv[1] = "-e"
argv[2] = "vi"
argv[3] = "some file"
argv[4] = 0
That is (repeating my earlier comment), the quotes around "some file"
are removed by the shell that invokes x-terminal-emulator. The program
(such as xterm) manipulates the argv[] array, and can for instance
construct a command to pass using a shell's "-c" option, but in the
case you're describing, it would be pointless.
--
Thomas E. Dickey <[email protected]>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature

