Hi!
> > #!/bin/true
> >
> > Or maybe more robust:
> >
> > #!/bin/sh
> > true
> >
> > But I'm not sure if there is always /bin/true (as it's buildin in most of 
> > the
> > shells) or if I it's good idea to add dependecy for /bin/sh. But this would
> > avoid compiling dummy C program and copying it from $LTPROOT/testcases/bin/.
> >
> > Or we could do some trickery to embed the "dummy" binary file into the code 
> > as
> > array.
> 
> It could just be an empty file, or one with just a shebang. Example:
> 
> [gcoo...@bayonetta ~]$ ./bar
> [gcoo...@bayonetta ~]$ echo $?
> 0
> [gcoo...@bayonetta ~]$ cat bar
> #!/bin/sh
> 
> `:' is an alternative to `true' too.

I did a little research what is going on when file is executed (and what is
standardized by POSIX).

Accordingly to posix standard, path to sh cannot be assumed /bin/sh either
/usr/bin/sh. However when file is executed by execlp() and kernel returns
ENOEXEC (because no binfmt handler was found for such file) it end up executed
by sh. So empty file (and wrong path to sh in shebang) should be safe as far as
kernel returns ENOEXEC (and as far as I understand sys_execve and friends from
linux/fs/exec.c this is true in case nobody plays with binfmt handlers) and
maybe may fail in very non standart enviroments. The most robust way seems to
be to look for sh in $PATH and create shebang accordingly.

Any thoughts?

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to