I am on Linux Mint 19.03
First of all, I can assure you that I have read most of the possible questions you might think this question of mine is a duplicate of.
Now, I basically want to type something in my terminal window to open a new terminal window and execute the commands.
Something like this:
[the part I am asking of] "echo $PATH; read"
This code should do open a new terminal, the $PATH variable should be displayed and read is just for halting the terminal.
I tried x-terminal-emulator -e
or x-terminal-emulator -c
or -x
but I could never achieve to do this correctly.
All answers on this SE on the similar questions are both old answers and were using -e or -x but it says that those options are deprecated.
So, what is the most proper way of achieving this?
Thanks.
-e
or-x
;-). The problem with-e
in gnome-terminal and alike is that they don't pass the (single!) argument to a shell via-c
but are actually parsing it themselves, and doing it BADLY. That's why the accepted answer works, because it's using a real shell.x-terminal-emulator -- sh -c 'echo $PATH; read'
would've worked, too, with less quote clutter. – Apr 12 '20 at 23:20-e
is still the only way you could pass a command to terminal emulators likexterm
ormlterm
(and even those have different, strange ideas of what the arguments after-e
mean), so there's no general solution. – Apr 12 '20 at 23:25x-terminal-emulator
– muyustan Apr 12 '20 at 23:25bash
instead ofsh
(which on debian and alike is a different shell,dash
, where theread
without a variable name is an error)x-terminal-emulator -- bash -c 'echo $PATH; read'
. Sorry for that, I should've tested it. – Apr 12 '20 at 23:29x-terminal-emulator
is wrapper. What terminal emulator exactly does it wrap to on your system? Does it still not work if you run it directly asgnome-terminal
ormate-terminal
? – Apr 12 '20 at 23:39muyustan@mint:~$ update-alternatives --display x-terminal-emulator x-terminal-emulator - auto mode link best version is /usr/bin/gnome-terminal.wrapper link currently points to /usr/bin/gnome-terminal.wrapper link x-terminal-emulator is /usr/bin/x-terminal-emulator slave x-terminal-emulator.1.gz is /usr/share/man/man1/x-terminal-emulator.1.gz /usr/bin/gnome-terminal.wrapper - priority 40 slave x-terminal-emulator.1.gz: /usr/share/man/man1/gnome-terminal.1.gz
– muyustan Apr 12 '20 at 23:45gnome-terminal
, which I also was thinking so. However, surprisingly, replacingx-terminal-emulator
withgnome-terminal
, it worked. I did not understand why actually. A more readable output by the way :muyustan@mint:~$ update-alternatives --list x-terminal-emulator
-->/usr/bin/gnome-terminal.wrapper
– muyustan Apr 12 '20 at 23:47x-terminal-emulator
(which is a perl wrapper), does not support thegnome-terminal -- cmd and args
form which is "recommended" new way. Your first attempt failed for the same reason as my first suggestion -- that wrapper tries to be smart and turns the-e cmd
intosh -c cmd
, but the defaultsh
on your system doesn't supportread
without an argument. If you usedread f
in the 1st place, your attempt would've worked. – Apr 12 '20 at 23:54x-terminal-emulator -e bash -c '...'
orgnome-terminal -- bash -c '...'
will work, butx-terminal-emulator -e '...'
orgnome-terminal -e '...'
will get you into trouble if the'...'
is anything but a simpleprogram arguments...
command. – Apr 12 '20 at 23:59muyustan@mint:~$ sh
$ read
sh: 1: read: arg count
each line seperated by a space. Thanks for all help. You should consider to compile these comments in an answer, it might be useful – muyustan Apr 13 '20 at 00:00