bats
is a shell script, however shebangs (#!
) can solely level to binaries, to not shell scripts. The rationale for that is that the execve()
system name (which reads a file to be executed) does not deal with oblique execution, it both expects a binary or a file beginning with #! /path/to/binary
.
This makes #!/usr/bin/env bats
the one method to make these scripts work.
From execve(2)
:
execve() transforms the calling course of into a brand new course of. The brand new course of is
constructed from an extraordinary file, whose title is pointed to by path, referred to as the
new course of file. This file is both an executable object file, or a file of
knowledge for an interpreter. An executable object file consists of an figuring out
header, adopted by pages of information representing the preliminary program (textual content) and
initialized knowledge pages. Further pages could also be specified by the header to be
initialized with zero knowledge; see a.out(5).
An interpreter file begins with a line of the shape:
#! interpreter [arg ...]
When an interpreter file is execve()'d, the system runs the required interpreter.
If any non-obligatory args are specified, they turn out to be the primary (second, ...) argument
to the interpreter. The title of the initially execve()'d file turns into the
subsequent argument; in any other case, the title of the initially execve()'d file is
the primary argument. The unique arguments to the invocation of the interpreter
are shifted over to turn out to be the ultimate arguments. The zeroth argument, usually the
title of the execve()'d file, is left unchanged.