Alan Hargreaves' Blog

The ramblings of a former Australian SaND TSC* Principal Field Technologist

ksh93 ENOEXEC errors solved

If you have been following my blogs on transitioning to an OpenSolaris SPARC based Sun Ray server (part 1 and part 2) you would have seen my frustration at the errors I was getting like:

make: sh: cannot execute [Exec format error]
make: sh: cannot execute [Exec format error]
make: sh: cannot execute [Exec format error]
sh: make: function not defined
*** Error code 126

I did some poking around today. I noticed that the stack in the writing of that error message looked like:


It’s trying to treat make as if it were a shell function. Huh? of course that’s not going to work.

Inside path_absolute in libshell I found the following:

    767                 isfun = (pp->flags&PATH_FPATH);

Further down this is checked and if it is, the file is opened to be read as a shell script.


Heading to the man page we see:

     FPATH         The search path for function definitions.  The
                   directories  in  this  path are searched for a
                   file with the same name  as  the  function  or
                   command  when a function with the -u attribute
                   is referenced and when a command is not found.
                   If  an  executable  file with the name of that
                   command is found, then it is read and executed
                   in  the  current environment. Unlike PATH, the
                   current directory must be  represented  expli-
                   citly by dot (.) rather than by adjacent colon
                   (:) characters or a beginning or ending  colon

Now if I add in the fact that I construct my $PATH using $FPATH and $LPATH (among others) a light begins to dawn.

My $FPATH actually contained almost the entirety of my normal path. So, ksh93 (which is also /bin/sh on OpenSolaris) was assuming that anything in any of those directories was a script to be read and parsed, without having to check.

I changed the names of those variables and everything there is now working as it should.


Written by Alan

April 13, 2010 at 9:20 pm

Posted in DTrace, OpenSolaris, Work

%d bloggers like this: