Bug 225563

Summary: clicking on a shell script will run it silently, instead of running it in konsole or other terminal emulator.
Product: [Applications] dolphin Reporter: aapgorilla <godutchnow>
Component: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: 501337, adaptee, adrian, arjunak234, emmanuelpescosta099, kde, konsole-devel
Priority: NOR    
Version: 2.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Ask before executing scripts

Description aapgorilla 2010-02-04 23:40:32 UTC
Version:            (using KDE 4.4.0)
OS:                Linux
Installed from:    Mandriva RPMs

this is valid for both plasma and dolphin: clicking on a script file does nothing the script is executable and the same scripts launch fine in both gnome and xfce and I can even run the script from konsole but clicking it does nothing at all....
Comment 1 Nicolas L. 2010-02-07 01:31:58 UTC
i think that this is a konsole issue, can i  commit this patch ?


+--- apps/konsole/desktop/konsole.desktop
++++ apps/konsole/desktop/konsole.desktop       2010-01-07 11:20:06.000000000 +0100
+@@ -5,6 +5,7 @@
+ X-DocPath=konsole/index.html
+ Terminal=false
+ X-KDE-StartupNotify=true
++MimeType=text/x-shellscript;
+ 
+ Name=Konsole
+ Name[af]=Konsole
Comment 2 Peter Penz 2010-02-07 15:23:55 UTC
@Nicolas: Thanks for the patch! Could you please post your patch to review.kde.org? It is not in the responsibility of Dolphin and I cannot decide whether it should be committed. Thanks!
Comment 3 aapgorilla 2010-02-07 22:36:28 UTC
(In reply to comment #1)
> i think that this is a konsole issue, can i  commit this patch ?
> 
> 
> +--- apps/konsole/desktop/konsole.desktop
> ++++ apps/konsole/desktop/konsole.desktop       2010-01-07 11:20:06.000000000
> +0100
> +@@ -5,6 +5,7 @@
> + X-DocPath=konsole/index.html
> + Terminal=false
> + X-KDE-StartupNotify=true
> ++MimeType=text/x-shellscript;
> + 
> + Name=Konsole
> + Name[af]=Konsole

Hi neoclust, was this the patch you included in mdv earlier? I think it only works partially, eg running opera from these tarballs in the link below doesnt work in kde but does in gnome/xfce:

http://snapshot.opera.com/unix/snapshot-6208/
Comment 4 Nicolas L. 2010-02-09 16:33:43 UTC
Done here : http://reviewboard.kde.org/r/2865/  i will look now why the opera one doesn't work
Comment 5 Nicolas L. 2010-02-09 16:42:15 UTC
the message is : 

The Opera binary is not located at "usr/lib/opera/opera".                                                                                    
Please modify the wrapper script at "/home/neoclust/Bureau/opera-10.50-6208.x86_64.linux/opera".

so it tries to start the script but there was something wrong
Comment 6 aapgorilla 2010-02-09 16:45:50 UTC
(In reply to comment #5)
> the message is : 
> 
> The Opera binary is not located at "usr/lib/opera/opera".                       
> Please modify the wrapper script at
> "/home/neoclust/Bureau/opera-10.50-6208.x86_64.linux/opera".
> 
> so it tries to start the script but there was something wrong

Ah now I remember, the script should be run from the current dir but this patch runs all scripts from $HOME
Comment 7 L Nix 2010-10-06 23:02:42 UTC
How is this a Konsole bug?  Konsole is a terminal emulator, nothing more.

This may be a dolphin bug.  But certainly not Konsole.  Clicking on something displayed in a Konsole session might highlight it, might use your browser (konqueror/firefox/iceweasel/opera/chome) to open a link, might copy something to the clipboard.  But clicking on something displayed in a Konsole session should never execute anything.  That's what konqueror/dolphin/whatever file-browser you prefer is supposed to do.

Very odd. Not a Konsole bug.
Comment 8 Jekyll Wu 2011-07-24 10:06:07 UTC
This is definitely not a bug of konsole.

If konsole is invoked but fails to show up and run that script, that is konsole's bug. But if konsole never got invoked by dolphin, it's not konsole's fault.

I have update my konsole.desktop as described in comment #1 and set konsole as default terminal emulator in systemsettings. And here is the proof :

1). choose a long-running or never-ending shell script, click it in dolphin. Nothing happens. But if you use ps command, you will find that script is running and its parent is dolphin. In my example, it shows like this :

USER       PID  PPID %CPU %MEM    VSZ   RSS TTY      STAT POL WCHAN  START   TIME COMMAND
whodare  11699 28087  9.2  1.6 226648 51728 ?        sl   ts  poll_s 17:29   0:02 kdeinit4: dolphin [kdeinit] --icon system-file-manager -caption dolphin
whodare  11731 11699  0.0  0.0   6640  1312 ?        s    ts  wait   17:29   0:00 /bin/bash /home/whodare/bin/crontab/pull-source-code.sh

  That implies dolphin never invokes konsole, but invokes the script itself instead .

2). another proof which looks more convincing:

  a). write a simple wrapper for konsole and save it as ~/bin/konsole (executable, of course), like this :

    #!/bin/bash
    echo /usr/bin/konsole --nofork $@ >> ~/konsole.log
    /usr/bin/konsole --nofork $@

  2). start dolphin by 'path=$HOME/bin:$PATH dolphin', and click some shell script.

  3). nothing was written into ~/konsole.log, because ~/bin/konsole was not invoked. 

So, this should not be a bug of konsole.
Comment 9 Jekyll Wu 2011-08-01 14:54:07 UTC
Assign it to dolphin because it is unlike a issue of konsole. See comment #7 and #8.
Comment 10 Jekyll Wu 2011-09-19 23:47:07 UTC
maybe related with bug #124681
Comment 11 Jekyll Wu 2011-09-22 21:33:56 UTC
maybe related with bug #241580
Comment 12 Jekyll Wu 2011-09-22 23:39:20 UTC
*** Bug 179863 has been marked as a duplicate of this bug. ***
Comment 13 Jeroen van Meeuwen (Kolab Systems) 2012-08-24 16:18:42 UTC
Resetting assignee to default as per bug #305719
Comment 14 Adrián Chaves (Gallaecio) 2012-10-27 10:57:31 UTC
Steps to reproduce:

1. Enter a folder other than $HOME.
2. Create a file in that folder named “test.sh”, with the following content:

#!/bin/bash
kdialog --msgbox $(pwd)

3. Give that file execution permissions:
    3.1. Open the Dolphin terminal (F4).
    3.2. Run chmod +x test.sh
    3.3. Close the Dolphin terminal (F4).
4. Click the “test.sh” file.

Expected results: It should show the current path.

It works for me in Dolphin 2.1 (Chakra).
Comment 15 Jekyll Wu 2012-10-27 11:52:48 UTC
Adrián, you miss the main point in this report: when a shell script is started by double clicking in dolphin,  konsole should be started to provide the running environment and give user the clear feedback that the script has been started.  Without that, there is no easy way to know whether that script has been started, unless you use ps command in another emulator to check for it .

In your example, you know the script has been started because that script happens to start a GUI application.  That is definitely not the common case.
Comment 16 Adrián Chaves (Gallaecio) 2012-10-27 13:31:44 UTC
I though the original report was about the script not being executed, which in turns was motivated by the script in question being executed from $HOME when launched from Dolphin.

If the issue is just that a console is not opened, shouldn’t it then be in the wishlist?
Comment 17 David Rosca 2013-04-25 20:42:37 UTC
Created attachment 79448 [details]
Ask before executing scripts

I made a simple patch that asks user before attempting to run any script (x-shellscript, x-python, ...) and offers to run it or open in editor.
It can be easily extended to add option "open in terminal", however i am not really sure how to run preferred terminal emulator (other than just explicitly run /usr/bin/konsole with QProcess or KRun::runCommand)
Comment 18 Frank Reininghaus 2013-04-30 11:21:24 UTC
Thanks for the patch, David. It applies rather to bug 172038 than to the present one though (even though both are certainly related).

The best way to submit patches is to upload them to https://git.reviewboard.kde.org/ and add the relevant people as reviewers. In this case, these should definitely include Jekyll Wu and David Faure because they did some work concerning the execution of scripts (see https://git.reviewboard.kde.org/r/107086/ and bug 275405 comment 12).

If we decide to implement the messaage box, we'll probably need a "Do not ask again"-like checkbox and a corresponding option in the settings. But before you work on that, I'd prefer to have a discussion with Jekyll, David and possibly others on ReviewBoard or the mailing list to decide which approach to take.
Comment 19 Arjun AK 2014-12-27 10:10:10 UTC
Now that we have 6fe41269df673215b88b52571b574ed575d81e6f (Get user's permission before executing scripts or desktop files), can't this be closed?
Comment 20 Emmanuel Pescosta 2014-12-28 19:54:10 UTC
(In reply to Arjun AK from comment #19)
> Now that we have 6fe41269df673215b88b52571b574ed575d81e6f (Get user's
> permission before executing scripts or desktop files), can't this be closed?

Yes I think so, thanks!