Skip to content
terminal

GitHub Action

Simple Shell Syntax Check

v2.2.0 Latest version

Simple Shell Syntax Check

terminal

Simple Shell Syntax Check

Uses shell '-n' to syntax check shellscripts

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Simple Shell Syntax Check

uses: Klintrup/simple-shell-syntax-check@v2.2.0

Learn more about this action in Klintrup/simple-shell-syntax-check

Choose a version

Simple shell syntax checker

Codacy Badge License Apache 2.0 Latest Release Contributors Issues build

Description

This GitHub Action, named "Simple Shell Syntax Check", is designed to perform syntax checks on shell scripts. The action takes an optional input 'files'. If provided, it will check the syntax of these specific files. If not provided, locate all .sh files in the current folder.

Inputs

Input required Description
files no list of files to be checked
install_missing_shell no Find missing shells and install

Output

Outputs status of each file to the action summary

supported shells

  • sh
  • bash
  • dash
  • fish
  • ksh
  • zsh

The shell must exist on the runner to be able to test. If the shell doesn't exist, that test will fail.

Installing shell on ubuntu-latest runner

You can install the shell before using this action

- name: Install fish
  run: sudo apt-get install -y fish

Or you can install all "missing" shells in a single command

- name: Install fish, ksh and zsh
  run: sudo apt-get install -y fish ksh zsh

instructions

Simple install (check all files named .sh)

- uses: actions/checkout@v4
- uses: Klintrup/simple-shell-syntax-check@v2

Install fish before running action

- uses: actions/checkout@v4
- run: sudo apt-get install -y fish
- uses: Klintrup/simple-shell-syntax-check@v2

Only validate files if changed (for pull request)

- uses: actions/checkout@v4
  with:
    ref: ${{ github.head_ref }}
    fetch-depth: 0
- name: Get changed files
  id: changed-files
  uses: tj-actions/changed-files@v40
  with:
    files: |
      **.sh
- uses: Klintrup/simple-shell-syntax-check@v2
  if: steps.changed-files.outputs.any_changed == 'true'
  with:
    files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
    install_missing_shell: true