Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem - executing two commands separated by a semicolon #203

Open
bohorok opened this issue Sep 7, 2023 · 7 comments
Open

Problem - executing two commands separated by a semicolon #203

bohorok opened this issue Sep 7, 2023 · 7 comments

Comments

@bohorok
Copy link

bohorok commented Sep 7, 2023

trying to do it:

xdg - autostart analyze, ^term(xdg-autostart -nv;read -n1) ,

I also tried this code

xdg - autostart analyze, tilix -e "xdg-autostart -nv ; read -n1" ,

in both cases nothing happens. The terminal appears for a fraction of a second without executing any command.
code:

xdg - autostart analyze, tilix -e "xdg-autostart -nv", 

In this case the command executes successfully and the terminal program closes.
Any command inserted after a semicolon, causes the terminal to appear for a fraction of a second without executing commands.
Jgmenu behaves as if it can execute only one command with options.
Could someone tell me what code to use to execute several commands in sequence. Is it possible in Jgmenu ?.

@napcok
Copy link

napcok commented Sep 7, 2023

This is tilix issue not jgmenu.

terminator -e "uname -a ; read -n1"

works fine.

tilix -e "uname -a ; read -n1"

Does not work.

You should check commands first by running them from terminal.

@johanmalm
Copy link
Collaborator

What @napcok said 😄

The semicolon only has meaning of parsed by a shell.

You could put multiple commands in a shell script and call that instead.

@johnraff
Copy link
Contributor

johnraff commented Sep 8, 2023

I think x-terminal-emulator's -e option is only supposed to work with a single command + arguments. Terminator's support for a multiple-command line is outside the spec. However, you can make sh or bashthe command, and then give it any shell code you like with the -c option. eg this works in prepend.csv:
test,x-terminal-emulator -e bash -c 'uname -a; echo "Press Enter to close"; read -srn1'
It should work with any terminal which supports "x-terminal-emulator", including tilix.

But if the compound shell code you want to run is long then you should follow @johanmalm 's advice and put it in a separate script.

@bohorok
Copy link
Author

bohorok commented Sep 8, 2023

Thank you all for your quick reply.
@johnraff

I think x-terminal-emulator's -e option is only supposed to work with a single command + arguments. Terminator's support for a multiple-command line is outside the spec.

This would mean that tilix is ​​behaving correctly ?.
Your save works fine for me. I also wanted to replace the name of the terminal emulator with a variable from the file: jgmenurc.

xdg - autostart analyze, ^term(bash -c  xdg-autostart -nv; echo "Press any key to close"; read -rn1) , 

unfortunately, it didn't work, but this save:

xdg - autostart analyze, $TERMINAL -e bash -c  'xdg-autostart -nv; echo "Press any key to close"; read -rn1' , 

work fine

But if the compound shell code you want to run is long then you should follow @johanmalm 's advice and put it in a separate script.

It is obvious to me that I should place longer scripts in separate files, csv files are not used for this.
@napcok
Thanks for leading me on, I didn't think terminal emulators could behave so differently, it's a bit strange.

@johnraff
Copy link
Contributor

johnraff commented Sep 9, 2023

Many terminal emulators behave differently if they are called as x-terminal-emulator, compared with if you call them directly by their name. If you install eg tilix on a Debian system, set it as x-terminal-emulator, then call x-terminal-emulator -e "some command" the -e option should work.
I haven't used tilix, except for a quick test, but I think it's behaving correctly.
Terminator also supports -e correctly if it is set as x-terminal-emulator.

Another less important difference is if a terminal supports -T for setting a title. Again, some do and some don't...

The Debian requirements for a terminal that claims to provide x-terminal-emulator: https://www.debian.org/doc/debian-policy/ch-customized-programs.html#packages-providing-a-terminal-emulator

@bohorok
Copy link
Author

bohorok commented Sep 9, 2023

@johnraff
I don't use Debian distribution, I use clean Arch + i3 wm. I found a command that is equivalent packet x-terminal-emulator : i3-sensible-terminal.

xdg - autostart analyze, i3-sensible-terminal -e 'xdg-autostart -nv ; echo "Press any key to close" ; read -rn1' , 

This notation would be the most convenient for me, but it doesn't work.
So I'll stick with it:

xdg - autostart analyze, $TERMINAL -e bash -c  'xdg-autostart -nv ; echo "Press any key to close" ; read -rn1' , 

@johnraff
Copy link
Contributor

Right, even without x-terminal-emulator, while some terminals support multiple commands after -e, it's safer to use bash -cor sh -c the way you did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants