[haiku-development] xicon and executable scripts

  • From: pete.goodeve@xxxxxxxxxxxx
  • To: Haiku Development <haiku-development@xxxxxxxxxxxxx>
  • Date: Sat, 2 May 2009 22:44:21 -0700

Hi all,
   I've finally managed to join the Haiku community (!), with extreme thanks
to Scott McCreary who has provided me with a laptop able to run it.

However, my first attempt to port a BeOS app [actually the first I ever wrote,
I think] has hit a fairly solid wall, so I need to see what can be done.
The app is 'xicon', which *I* find indispensable [and I simply can't understand
why no one else seems to! (:-/)].  I think about 90% of my icon clicks are
on an xicon script.   If you're not familiar, it runs shell scripts (or Python
or Ruby, or...) in a Terminal window.  It's true this can be done without xicon
-- in a slightly kludgey way -- but the important thing about xicon is that
one can drag and drop files onto the icon and they get passed as arguments
to the script.

To explain the problem, I'd better first quickly go through how xicon's
scripts are set up, and how this works under BeOS.  First, of course, the
script is set with xicon as the Preferred App, but in addition the 'x-bit'
of the permissions must be set.  The latter is required so that other files
can be dropped on it, and Tracker will pass the refs on, but it's not sufficient
by itself because Tracker wants to know which filetypes are actually relevant.
So the attributes must include BEOS:FILE_TYPES; currently this is simply always
'application/octet-stream', so any file can be dropped, but in theory it could
be set to be more specific.

That's all that BeOS really needs to invoke xicon, but BEOS:TYPE is normally
set to 'text/x-script.xicon' (or a couple of other alternatives) so xicon
knows the action to take.  The "#! /bin/sh" as the first line of a script
is not actually needed at all, because the shell is invoked on it directly.

Now in Haiku, things happen a bit differently.  Specifically, setting the
x-bit apparently causes the Tracker to ignore the Preferred App completely.
Instead it goes immediately to check for the "#!..." line, and if that
isn't present throws up an error alert!  So there's no way I can do the
drag&drop thing.  I can leave off the x-bit and get a clickable script,
which is OK for some things, but prohibits a lot of the things I use
the app for.  [There's another problem apparently connected with load_image,
but I'd rather get at the first problem first.]

I don't see any advantage in the sequence Haiku uses over the old BeOS one
(please point it out if there is), so I'm hoping someone can do a patch.
[Don't think I'm quite ready yet to do this sort of thing myself!]
I've always thought that there are severe hazards with the way BeOS handles
shell scripts [topic for later...], but the Haiku scheme doesn't fix them.

                                        -- Pete --


Other related posts: