Skip to content

Files

Latest commit

 

History

History
27 lines (18 loc) · 565 Bytes

SC3054.md

File metadata and controls

27 lines (18 loc) · 565 Bytes

Pattern: Use of undefined array reference

Issue: -

Description

Arrays are supported in bash and ksh, but not in dash or POSIX sh. Either switch to a shell that supports them, or rewrite your script without relying on arrays. This may not be straight forward.

Example of incorrect code:

#!/bin/sh
var=(foo bar)
echo "${var[1]}"

Example of correct code:

#!/bin/bash
var=(foo bar)
echo "${var[1]}"

Further Reading