terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Elementary terminal does not properly respect -e flag

Open DanyGee opened this issue 6 years ago • 15 comments

would like to automate showing of a nice weather report you can launch in terminal: curl wttr.in/bydgoszcz screenshot from 2018-10-17 14 46 16 2x with follwoing script launched from the system menu:

#!/bin/sh
exec io.elementary.terminal -e "curl wttr.in/bydgoszcz"

But this way the output gets a little "incomplete", just like if the command got executed too fast (notice where the user@machine line went here): screenshot from 2018-10-17 14 46 45 2x So, is there a way to delay the command after -e flag? Or maybe totally different approach will automate this to show the output properly?

Tried also this:

#!/bin/sh
WTTR=$(curl -s wttr.in/bydgoszcz) && \
exec io.elementary.terminal -e "echo $WTTR"

but it produced this: screenshot from 2018-10-18 22 11 53 2x When doublequoted - -e "echo "$WTTR"" - the output is single word - weather When tried -e 'echo "$WTTR" ' - output is $WTTR When tried -e echo "$WTTR" - the output is empty line

After trying this:

#!/bin/sh
exec io.elementary.terminal -e "sleep1s & curl wttr.in/bydgoszcz"

The output is a single dot... screenshot from 2018-10-18 19 58 55 2x ...and once the terminal gets closed in this case, the whole user session gets restarted! :astonished: I've run out of ideas :face_with_head_bandage: help me


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

DanyGee avatar Oct 25 '18 12:10 DanyGee

Probably related to (or even the same as) VTE 777686.

egmontkob avatar Oct 25 '18 18:10 egmontkob

I can't get there to be a new tab with passed commands. dunnow what I'm doing wrong :

 io.elementary.terminal -e "echo hi; sleep 6"

new tab opens with commands echoed. and stays open.

tatsujb avatar Apr 15 '19 15:04 tatsujb

At the moment the -e option can only cope with a single command, not sequential commands. So to execute multiple sequential commands, they would have to be put into a script and then execute that with -e.

jeremypw avatar Apr 15 '19 19:04 jeremypw

this cannot do. I'm trying to port a script from ubuntu to elementary. I can't have the script execute the code saved in a variable for one and the code exported to a script file for the other that's way too much redundant code.

I really think feature parity with the base should be attained before switching to something else.

in this case the base you're working from is ubuntu, gnome-terminal has a basic amount of functionality.

I'd like for elementary terminal to have feature-parity.

tatsujb avatar Apr 15 '19 21:04 tatsujb

What was the equivalent gnome-terminal script?

jeremypw avatar Apr 16 '19 15:04 jeremypw

notice the comment at 558. I'm having to resort to xterm to get it to run.

my script : https://github.com/tatsujb/installFAFscript

short story :

gnome-terminal --tab --active --title="install & run steam, steamcmd, FA" -- bash -c 'do all the things that I want to do in a new windows, including but not limited to opening another window with a bunch of commands'

tatsujb avatar Apr 16 '19 15:04 tatsujb

Thanks. I'll see what can be done.

jeremypw avatar Apr 16 '19 15:04 jeremypw

@DanyGee : Try this command:

io.elementary.terminal -e "bash -c 'curl  wttr.in/bydgoszcz';'sleep 3'"

This works for me both typed directly into a terminal and when put in a script and run from Files (using the master version of Terminal).

jeremypw avatar Apr 16 '19 17:04 jeremypw

@tatsujb : Multiple bash commands are possible using nested quote marks as shown in the above comment. Not sure whether that is enough for your problem though.

jeremypw avatar Apr 16 '19 17:04 jeremypw

hey, again this is problematic, (it's this realistically) :

io_opening_faf_script='io.elementary.terminal -e "bash -c '"'"'curl  wttr.in/bydgoszcz'"'"';'"'"'sleep 3'"'"'"; '"'"''#trailing escaped colon to allow for a big evaluatable variable to fit after this

and does not solve the duplication of code issue :

every single line from line 343 to 526 would have to have an escaped colon : '"'"' at the start and at the end of the line. which might break the functioning for the other terminals (three of them, konsole, gnome-terminal and xterm) which right now are all able to use the same lines from 343 to 526 without unscoping.

tatsujb avatar Apr 16 '19 17:04 tatsujb

Yes, I guessed as much. I was just trying to give @DanyGee a solution to his particular problem.

Gnome-terminal is a much more complex program than elementary terminal so the code is not simply transferable unfortunately.

jeremypw avatar Apr 16 '19 17:04 jeremypw

but what about reverting to gnome-terminal for elementary?

I really see no good attribute or saving grace of io.elementary.terminal other than it being very slightly themed.

out-of the box gnome-terminal wouldn't look too estranged in elementary and it is themable to boot.

you could work your way towards elementary's looks instead of working your way towards gnome-terminal's functionality. (which surprisingly is apparently "low-tier functionality", so where does that leave io.elementary.terminal?)

tatsujb avatar Apr 16 '19 17:04 tatsujb

That is a discussion you would need to have with the elementary design team. I think they would disagree that elementary terminal is only "very slightly" themed. A significant amount of work beyond theming would be needed to make and maintain a similar gnome-terminal fork. Also elementary favors Vala programs and gnome-terminal is in C.

I'll look into why the extra quoting is needed for elementary terminal and whether it can be eliminated. At the moment the code just relies on Shell.parse_argv () to parse the command string. Maybe our own parser is needed.

jeremypw avatar Apr 16 '19 17:04 jeremypw

FYI I use this service from a much simpler script:

#!/bin/bash

curl wttr.in/${1}

I called it ~/bin/weather.sh (as I'm unable to remember "wttr.in") and it accepts location as an argument, e.g. weather.sh ostrava. I don't use the other features but they are the same kind of string so it should work fine too.

janxkoci avatar Dec 25 '19 23:12 janxkoci

@DanyGee Have you tried using the new -x flag instead of -e?
Screenshot from 2020-01-05 15 09 33

jeremypw avatar Jan 05 '20 15:01 jeremypw