Some Windows and Mac users will be surprised at this, some will laugh – and well they should. On Linux it’s not possible to just download a program and run it, not even if it’s a program for the right platform. How stupid is that?
The problem is that (probably for no-longer-relevant security reasons) any file you download using a web browser (over HTTP or FTP) will have read and write permissions for the user, and read (or nothing) for group and others – in other words -rw-r–r–, or 644. A double-click on the file in a file manager (or on the desktop) will get the system to think that it’s a data file that needs to be opened in another program, and usually a dialog will come up asking you what program you want to open this file (program) in. Arrrgh!
I’m asking around for a solution, but I suspect there is none. If that’s the case maybe I’ll try to fix it myself – the solution is a couple of lines in C.
Some background: it is possible to have a shell script (let’s call it program.sh) that has more than just shell commands. For example the Loki games installer is a shell script but it has a GUI and a few hundred binary files (possibly in an archive), all this in program.sh. There are other examples of this.
So let’s say we make a new file extension – .esh, for executable .sh, and these will actually be shell scripts, following all the rules of sh/bash. When one double-clicks on such a file in a file manager, the file manager will either:
- Execute the file if it has +x permissions, in which case it will act like a shell script, or
- Treat the file as a data file and will open it in the associated program – this will be my program which I will call esh
The program will be something like this:
/* esh.c */
int main(int argc,char** argv)
{
if(argc != 2) return -1;
exec("/bin/bash", "bash", argv[1], NULL);
}
/* thank you WordPress for deleting spaces at the beginning of a line. grrr */
So if the file manager runs ‘esh program.esh’ it will just execute /bin/bash program.esh, which is exactly what I want – it will give the illusion of a file being executed even if it doesn’t have execute permissions.
Of course then there is the matter of getting distributions to ship with esh installed by default – but maybe I’m not the only one who thinks this is a major misfeature in Linux, and it will get done quickly.
If I don’t find a different solution in a couple of weeks, I will probably go ahead and start pimping this one.