From 58b0e83655895f5d92c7c4c63ba4b79651703ee6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Jun 2018 17:28:30 +0200 Subject: [PATCH] Add env vars usage idiom for writing types --- docs/src/cdist-type.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index a6587328..7c0dab8d 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -331,6 +331,19 @@ So when you generate a script with the following content, it will work: fi +Environment variable usage idiom +-------------------------------- +In type scripts you can support environment variables with default values if +environment variable is unset or null by using **${parameter:-[word]}** +parameter expansion. + +Example using mktemp in a portable way that supports TMPDIR environment variable. + +.. code-block:: sh + + tempfile=$(mktemp "${TMPDIR:-/tmp}/cdist.XXXXXXXXXX") + + Log level in types ------------------ cdist log level can be accessed from __cdist_log_level variable.One of: