when a script is not a script according to krun...

David Faure faure at kde.org
Tue Mar 30 08:59:04 BST 2004


On Tuesday 23 March 2004 15:34, ian reinhart geiser wrote:
> Greetings,
> I have a question about scripts with KDE.  I have a few perl, python and
> javascript scripts that all open with a text editor always.  Now if i have
> a normal bash based shell script with a .sh ending it will open with a
> text editor when chmod -x and will open as an application if chmod +x.
I don't see this here: with chmod -x, nothing happens when clicking on a .sh file.
KRun tries to execute it, and 
/bin/sh: line 1: /k/kdialog.sh: Permission denied
Maybe it depends on the shell.

> I was unclear of  how we detect .sh files to run, although I think thats because I had no
> clue where to start and grep was unhelpful at that point.
krun.cpp executes files recognized as mimetype=="application/x-shellscript"
(since it also executes application/x-executable ones, etc. )

So the question is the mimetype determination.
The pattern *.sh is associated with application/x-shellscript, so any *.sh file
is a shellscript. Independently of +x permissions.

> The idea in my mind is that all files that have been chmod +x should try
> to be executed first, and if that fails if they are also of a mime type
> text/plain opened with a text editor.  This way pyQt/pyKDE, rubyQt and
> KJSEmbed  can be useful for doing applications in kde, without the ever
> popular windows issue of executing any script you try to open.

Actually I've read many bug reports stating that executing scripts when clicking
on them was dangerous and should be turned off or at least double-checked
("do you want to run <foo>?"). Imagine if you have a "rm -rf" script in $HOME
and never intend to click on it, but by mistake, one day.... But this holds for
many things, including .desktop files etc.

OTOH I don't know a good solution to that, so honouring the execute bit is 
also fine by me. I don't think we want to use a different mimetype depending
on it though, so this would require e.g. a modified version of KRun::isExecutable()
that also takes the mode of the file.
Then we can add perl/python/kjsembed scripts there and add a test +x for 
all mimetypes (except x-desktop).

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list