Artix Linux Forum

General Category => Off-Topic => Topic started by: tintin on 02 January 2022, 12:22:02

Title: [Solved] Script which "does not return my hand"
Post by: tintin on 02 January 2022, 12:22:02
Hello and bonjour,

As I read that it is better to use pacman than pamac to make the updates, I created a small script (yes, I'm too lazy or too in a hurry to write "sudo pacman -Syyu").

Here is the content of my sript:
Code: [Select]
#! /bin/bash
xfce4-terminal --maximize -H -x sudo pacman -Syyu

I put a launcher in the dashboard and the script launches fine, except it "does not return my hand"  (French expression).
In short: when the process is terminated, I do not see an information that the process is finished, or the line :
Code: [Select]
jp-artix:[jp]:~$

I searched, searched but found nothing, probably because I am trying to reinvent the wheel. Shame on me. :)

Thanks in advance for your suggestions.
Title: Re: Script which "does not return my hand"
Post by: nous on 02 January 2022, 15:13:39
It's because you're not starting a login shell, you're executing a script and its stdio/stdout/stderr are not connected to terminals but to xfce4-terminal's buffers.
Title: Re: Script which "does not return my hand"
Post by: tintin on 02 January 2022, 16:01:06
It's because you're not starting a login shell, you're executing a script and its stdio/stdout/stderr are not connected to terminals but to xfce4-terminal's buffers.
Ah OK.
Can I do it differently?
I seek, I seek, but cannot find ...
Title: Re: Script which "does not return my hand"
Post by: capezotte on 02 January 2022, 16:45:03
You can make xfce4-terminal spawn a sequence of commands that, after running your command, execs your preferred shell, giving you back control:

Code: [Select]
#!/bin/sh
exec xfce4-terminal --maximize -H -x sh -c 'sudo pacman -Syyu; exec bash'

Bonus for s6 users:
Code: [Select]
#!/bin/execlineb -P
xfce4-terminal --maximize -H -x foreground { sudo pacman -Syyu } unexport ? bash
Title: Re: Script which "does not return my hand"
Post by: calvinh on 02 January 2022, 16:49:42
Try this,

Code: [Select]
xfce4-terminal --maximize -H --tab -x sudo pacman -Syyu
Title: Re: Script which "does not return my hand"
Post by: tintin on 02 January 2022, 16:52:15
You can make xfce4-terminal spawn a sequence of commands that, after running your command, execs your preferred shell, giving you back control:

Code: [Select]
#!/bin/sh
exec xfce4-terminal --maximize -H -x sh -c 'sudo pacman -Syyu; exec bash'
Great !
I had tried to add something after ";" but I couldn't find ...

Thank you !  8)
Title: Re: Script which "does not return my hand"
Post by: tintin on 02 January 2022, 17:09:01
Code: [Select]
xfce4-terminal --maximize -H --tab -x sudo pacman -Syyu
It also works and allows you to continue.  8)
I couldn't find the --tab option in the manuals.
I note it!

But the order from Capezotte allows to keep the result of the previous order, which interests me more here.

Thank you !