Documentation ¶
Overview ¶
Package fileutil allows inspecting shell files, such as detecting whether a file may be shell or extracting its shebang.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasShebang ¶
HasShebang reports whether bs begins with a valid shell shebang. It supports variations with /usr and env.
Types ¶
type ScriptConfidence ¶
type ScriptConfidence int
ScriptConfidence defines how likely a file is to be a shell script, from complete certainty that it is not one to complete certainty that it is one.
const ( // ConfNotScript describes files which are definitely not shell scripts, // such as non-regular files or files with a non-shell extension. ConfNotScript ScriptConfidence = iota // ConfIfShebang describes files which might be shell scripts, depending // on the shebang line in the file's contents. Since CouldBeScript only // works on os.FileInfo, the answer in this case can't be final. ConfIfShebang // ConfIsScript describes files which are definitely shell scripts, // which are regular files with a valid shell extension. ConfIsScript )
func CouldBeScript
deprecated
func CouldBeScript(info os.FileInfo) ScriptConfidence
CouldBeScript is a shortcut for CouldBeScript2(fs.FileInfoToDirEntry(info)).
Deprecated: prefer CouldBeScript2, which usually requires fewer syscalls.
func CouldBeScript2 ¶
func CouldBeScript2(entry fs.DirEntry) ScriptConfidence
CouldBeScript2 reports how likely a directory entry is to be a shell script. It discards directories, symlinks, hidden files and files with non-shell extensions.