Skip to main content

is_script

Function is_script 

Source
pub fn is_script(input: &str) -> Result<Option<PathBuf>, String>
Expand description

Validates a script

Expands path and checks if it exists and is a file. Then checks whether the file is executable.

§Unix

On Unix this checks whether there are any executable bits in the file’s permissions (i.e. ‘-rwxrw–x’)

§Windows

On Windows this just checks whether the file ends in ‘.exe’, ‘.bat’, ‘.cmd’, ‘.com’, or ‘.ps1’.

Used in sericoms clap cli interface to validate user input and propogate errors before running the program.

§Errors

Errors if path-expansion fails, if the path doesn’t exist, is not a file, or is not executable according to the definitions in Unix and Windows respectively.