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.
-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 --
:
command "argument with spaces"
--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"