Bug 473268 - Whether File is "Executable" Depends on Extension, not Execute Bit
Summary: Whether File is "Executable" Depends on Extension, not Execute Bit
Status: RESOLVED UPSTREAM
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (show other bugs)
Version: 22.12.3
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-11 02:15 UTC by stellarpower
Modified: 2023-08-22 12:59 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stellarpower 2023-08-11 02:15:02 UTC
Whilst posix shells are traditionally the most common on linux, there are many options now. Not all shell scripts end in `.sh`, and whether a file can be executed or not is determined by the execute bit on linux - and not by any file extension or similar conventions. With many shells to choose from, and not to mention other languages, such as Ruby or Python, and the ability to have more complex shebanhgs, there's an increasing range of text files one might want to execute directly.

I use fish a lot, and now more nushell aswell, and whilst often I do want to open my scripts to edit them, it is also convenient to be able to execute them with a double-click with no arguments from within dolphin. I would like to be prompted if I want to open or execute an executable text file of any type, the same way I would if it is evidently a script for one of the posix-style shells. I think on linux, the execute bit trumps the extension, which seems to me to be a deciding factor. This is the behaviour I have had on Nemo (and I assume nautilus too). At the least, if there are disagreements on whether users would prefer this or not, I think this should be a configurable option. E.g. "Treat all files with execute bit set as executable" (for the purposes of determining whether to open in an application, execute, or always ask), or "Only treat certain known executable file formats as executable". 



On linux:

STEPS TO REPRODUCE
1. Create a shell script in a language of your choice.
1. Give it the extension ".sh"
1. Set the execute bit
1. Double-click in Dolphin. It should execute, or prompt, according to your preference in the settings.
1. Now name it ending in e.g. .fish., .nu, .xonsh, ...

OBSERVED RESULT
1. Double-clicking opens it in Kate (for me)


EXPECTED RESULT
1. Double-clicking it still executes it

SOFTWARE/OS VERSIONS
(Skipped as not sure is relevant)
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 stellarpower 2023-08-11 02:17:08 UTC
Don't see a "related" field above, so adding manually:
https://bugs.kde.org/show_bug.cgi?id=456356
Comment 2 stellarpower 2023-08-12 15:52:51 UTC
Symbolic links also seem to be affected - double-clicking a script ending in .sh executes it, whilst double-clicking a symlink in the same directory pointing to it, opens it in Kate.
Comment 3 Méven Car 2023-08-22 12:35:02 UTC
You can add ".fish" extension to mimetype `application/x-executable`.
It will then be recognized as executable by dolphin (an d KDE apps).

You can `keditfiletype5` utility to do so.
Comment 4 Méven Car 2023-08-22 12:59:02 UTC
FYI I submitted an upstream MR to add proper support for nu scripts and fish scripts everywhere:
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/231

Feel free to do the same for xonsh (or open a bug specific for it).