Skip to content

bash-exec

Checks if shell files are executable

Note: You can run git add --chmod=+x myfile.sh to make a file executable on Windows

bash-exec documentation

Configuration in MegaLinter

Variable Description Default value
ERROR_ON_MISSING_EXEC_BIT If set to false, the bash-exec linter will report a warning if a shell script is not executable. If set to true, the bash-exec linter will report an error instead false
BASH_EXEC_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
BASH_EXEC_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
BASH_EXEC_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
BASH_EXEC_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
BASH_EXEC_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- project: Call the linter from the root of the project
file
BASH_EXEC_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
["", ".sh", ".bash", ".dash", ".ksh"]
BASH_EXEC_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
BASH_EXEC_PRE_COMMANDS List of bash commands to run before the linter None
BASH_EXEC_POST_COMMANDS List of bash commands to run after the linter None
BASH_EXEC_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling BASH_EXEC and its pre/post commands None
BASH_EXEC_DISABLE_ERRORS Run linter but consider errors as warnings false
BASH_EXEC_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
BASH_EXEC_CLI_EXECUTABLE Override CLI executable ['bash-exec']

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 124 Docker Image Size (tag) Docker Pulls
c_cpp Optimized for pure C/C++ projects 54 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 83 Docker Image Size (tag) Docker Pulls
documentation MegaLinter for documentation projects 49 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 62 Docker Image Size (tag) Docker Pulls
dotnetweb Optimized for C, C++, C# or VB based projects with JS/TS 71 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 51 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 52 Docker Image Size (tag) Docker Pulls
javascript Optimized for JAVASCRIPT or TYPESCRIPT based projects 59 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 54 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 62 Docker Image Size (tag) Docker Pulls
ruby Optimized for RUBY based projects 50 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 50 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 54 Docker Image Size (tag) Docker Pulls
security Optimized for security 24 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 50 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 54 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: `,.sh,.bash,.dash,.ksh`
  • Detected file content (regex): ^#!/usr/bin/env bash, ^#!/bin/bash, ^#!/bin/sh

How the linting is performed

  • bash-exec is called one time by identified file (file CLI lint mode)

Example calls

bash-exec myfile.sh

Help content

GNU bash, version 5.2.26(1)-release-(x86_64-alpine-linux-musl)
Usage:  bash [GNU long option] [option] ...
  bash [GNU long option] [option] script-file ...
GNU long options:
  --debug
  --debugger
  --dump-po-strings
  --dump-strings
  --help
  --init-file
  --login
  --noediting
  --noprofile
  --norc
  --posix
  --pretty-print
  --rcfile
  --restricted
  --verbose
  --version
Shell options:
  -ilrsD or -c command or -O shopt_option    (invocation only)
  -abefhkmnptuvxBCEHPT or -o option
Type `bash -c "help set"' for more information about shell options.
Type `bash -c help' for more information about shell builtin commands.
Use the `bashbug' command to report bugs.

bash home page: <http://www.gnu.org/software/bash>
General help using GNU software: <http://www.gnu.org/gethelp/>

Installation on mega-linter Docker image

  • Dockerfile commands :
RUN printf '#!/bin/bash \\n\\nif [[ -x "$1" ]]; then exit 0; else echo "Error: File:[$1] is not executable"; exit 1; fi' > /usr/bin/bash-exec \
    && chmod +x /usr/bin/bash-exec