Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 645 Bytes

SC3047.md

File metadata and controls

27 lines (17 loc) · 645 Bytes

Pattern: Trapping ERR is undefined

Issue: -

Description

You are trying to install a trap that is not supported by your current shell (dash or POSIX sh). There is no simple replacement. The script should be rewritten to avoid depending on the trap, or simply be run with a shell that supports it.

Also applies to RETURN and DEBUG.

Example of incorrect code:

#!/bin/sh
trap 'Command failed with $?' ERR

Example of correct code:

#!/bin/bash
trap 'Command failed with $?' ERR

Further Reading