From ec8e5a871d98cc16ebb3fee1e2124f292fa13c30 Mon Sep 17 00:00:00 2001 From: Nicolas Dechesne Date: Wed, 25 Jan 2017 09:18:16 +0100 Subject: automated: sh-test-lib: do not source /etc/lsb-release If /etc/lsb-release file exists , then it will be sourced in dist_name() so any variable defined in this file will override/pollute our existing environment. Since dist_name() is called in the context of the test script, we might end up polluting our test environment with unneeded variable, or even worse we might override variables that we have set in our test scripts... Instead of sourcing the file in the current env, let's do it in a subshell. Change-Id: I99ff9b7bb498f47f01adfe0d21f9b1cce0ebf2cc Signed-off-by: Nicolas Dechesne --- automated/lib/sh-test-lib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'automated/lib') diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index 29fd8f9..39b65cd 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -154,8 +154,8 @@ dist_name() { if [ -x /usr/bin/lsb_release ]; then dist="$(lsb_release -si)" elif [ -f /etc/lsb-release ]; then - . /etc/lsb-release - dist="${DISTRIB_ID}" + # shellcheck disable=SC1091 + dist="$(. /etc/lsb-release && echo "${DISTRIB_ID}")" elif [ -f /etc/debian_version ]; then dist="Debian" elif [ -f /etc/fedora-release ]; then -- cgit v1.2.3