2

I'm trying to open a terminal that shows a file as it's being written. A progress percentage is written into the file and I'd like the user to see it.

Most solutions I have found for opening a new terminal say to use -e, but that returns

# Option "-e" is deprecated and might be removed in a later version of gnome-terminal
# Use "-- " to terminate the options and put the command line to execute after it.

I've seen discussion about this error, but I'm still unsure as to what the functional difference between -e and -- actually is. Scripts that I run that use -e stop working properly if I just swap them, so there's obviously something that I'm missing.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
justmayo
  • 41
  • 1
  • 6
  • -e option to ... what? gnome-terminal? – glenn jackman Jul 28 '20 at 17:31
  • @glennjackman yes. "e" stands for "execute". See [the manual](https://manpages.ubuntu.com/manpages/bionic/en/man1/gnome-terminal.1.html). – wjandrea Jul 28 '20 at 17:34
  • @glennjackman yes – justmayo Jul 28 '20 at 17:35
  • I think it's telling you that if you used to use `gnome-terminal … -e 'command with args to execute' …`, you should now use `gnome-terminal … … -- command with args to execute` instead, because at some time in the next 20 years, the `-e` option will be removed. Note that the `-e` option probably could appear between other control options, hence the two lots of `…` in my outline code. If it had to appear at the end, followed by the command name and options, you shouldn't spot a difference when changing from `-e` to `--`, so I assume that it wasn't like that (but you know what `ass*u*me` does). – Jonathan Leffler Jul 28 '20 at 17:41

1 Answers1

4

-e would take a single argument which would have to be parsed as a shell command, but it could precede other gnome-terminal arguments. For example,

gnome-terminal -e 'command "argument with spaces"' --some-other-gnome-terminal-option

-- is not itself an option; it's a special argument that signals the end of options. Anything following -- is ignored by gnome-terminal's own option parser and treated like an ordinary argument. Something like

gnome-terminal -- 'command "argument with spaces"' --some-other-gnome-terminal-option

would present 2 additional arguments to gnome-terminal following the --:

  1. command "argument with spaces"
  2. --some-other-gnome-terminal-option

Further, you would get an error, because gnome-terminal would attempt to run a command named command "argument with spaces", rather than a command named command.


In practice, this means you can't simply replace -e with -- and call it a day. Instead, you would first move -e to the end of the options list:

gnome-terminal --some-other-gnome-terminal-option -e 'command "argument with spaces"' 

then replace -e '...' with -- .... The command and each of its arguments are now distinct arguments to gnome-terminal, which removes the need for an entire layer of quoting.

gnome-terminal --some-other-gnome-terminal-option -- command "argument with spaces"
chepner
  • 497,756
  • 71
  • 530
  • 681
  • ...and if you have been using `-e` to launch different programs in multiple tabs [you are apparently in serious trouble](https://stackoverflow.com/questions/52764599/opening-new-gnome-terminal-v3-28-with-multiple-tabs-and-different-commands). What an unfortunate deprecation decision. – bluenote10 Mar 04 '21 at 09:32