[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#648271: [debian-policy] 11.8.3 "Packages providing a terminal emulator" says xterm passes -e option straight to exec



On Sun, Dec 25, 2011 at 12:28:22AM -0800, Russ Allbery wrote:
> There's some mail client that seems to mangle messages that contain words
> inside angle brackets.  Apparently Mozilla?  It's doing weird things to
> the whitespace when you quote.
> 
> Filipus Klutiero <chealer@gmail.com> writes:
> 
> > I would simply suggest as a replacement:
> 
> >>      Support the command-line option "-e <command>", which creates a
> >>      new terminal window and runs the specified simple command.
> >>      <command> may be multiple arguments, all of which are part of the
> >>      simple command.  All arguments are passed directly to exec,
> >>      bypassing the shell.  (xterm's behavior of falling back on using
> >>      the shell if -e had a single argument and exec failed is
> >>      permissible but not required.)
> 
> > (<command> could be replaced by <simple command>, but I think that will
> > be clear enough already.)
> 
> I'm not sure that simple command is going to be any more intuitive to
> people for whom the mention of exec doesn't get it across.  Maybe we
> should say something like "...specified simple command, by default not
> using the shell"?  I can't tell if your main concern is clarifying that &&
> or | or the like don't work, or something else.

either way, xterm is using exec to run the command.
The shell helps, but is not the primary mechanism.
Read the code :-)
 
> >> 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().

well, that's different from saying that it uses 'exec'.  The shell
handles quotes before xterm sees "some file", and xterm sees only the
dequoted string as a single entry in argv[].

Regarding a recent change to check for -h / -v options at the end of the
argument list, when using X Toolkit, xterm has the additional problem of
checking for items that may be removed from argv[] during
initialization.  (The other toolkits have similar issues, of course).

Left out of the discussion is a more interesting feature - whether the
program should use the "p" or "e" variants of exec.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


Reply to: