From 56222d1f856a9770383c9c9dfa99d785a50121c5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Jun 2012 16:14:28 +0200 Subject: [PATCH] document stdin reading Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-type.text | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/man/man7/cdist-type.text b/doc/man/man7/cdist-type.text index 92a2b36d..ed114aff 100644 --- a/doc/man/man7/cdist-type.text +++ b/doc/man/man7/cdist-type.text @@ -111,6 +111,33 @@ fi -------------------------------------------------------------------------------- +INPUT FROM STDIN +----------------- +Every type can access what has been written on stdin when it has been called. +The result is saved into the ***stdin*** file in the object directory. + +Example use of a type: (e.g. in conf/type/__archlinux_hostname) +-------------------------------------------------------------------------------- +__file /etc/rc.conf --source - << eof +... +HOSTNAME="$__target_host" +... +eof +-------------------------------------------------------------------------------- +If you have not seen this syntax (<< eof) before, it may help you to read +about "here documents". + +In the __file type, stdin is used as source for the file, if - is used for source: +-------------------------------------------------------------------------------- + if [ -f "$__object/parameter/source" ]; then + source="$(cat "$__object/parameter/source")" + if [ "$source" = "-" ]; then + source="$__object/stdin" + fi + .... +-------------------------------------------------------------------------------- + + WRITING THE MANIFEST -------------------- In the manifest of a type you can use other types, so your type extends