Skip to content

Files

Latest commit

 

History

History
30 lines (18 loc) · 687 Bytes

SC2240.md

File metadata and controls

30 lines (18 loc) · 687 Bytes

Pattern: Use of unsupported . command

Issue: -

Description

In Bash and Ksh, you can use . samplescript arg1 arg2.. to set $1 and $2 in the sourced script.

This is not the case in Dash, where any additional arguments are ignored, or in POSIX sh where the behavior is unspecified.

Instead, assign arguments to variables and rewrite the sourced script to read from them.

Example of incorrect code:

#!/bin/sh
. include/samplescript example.com 80

Example of correct code:

#!/bin/sh
host=example.com port=80 . include/samplescript 

Further Reading