From 2b955b09bc92fbb88023ae5986b9d2ebb9360119 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 5 Sep 2011 10:01:56 +0200 Subject: [PATCH] move out all functions that do not only print a value from bin/cdist-config Signed-off-by: Nico Schottelius --- bin/cdist-config | 19 ------------------- core/__cdist_kill_on_interrupt | 31 +++++++++++++++++++++++++++++++ core/__cdist_tmp_removal | 27 +++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 core/__cdist_kill_on_interrupt create mode 100755 core/__cdist_tmp_removal diff --git a/bin/cdist-config b/bin/cdist-config index be65fed3..87f24d06 100644 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -165,11 +165,6 @@ for __cdist_lib in $__cdist_core_dir/*; do . "$__cdist_lib" done -___cdist_lib_path() -{ - echo $_ -} - ################################################################################ # Cache @@ -213,7 +208,6 @@ __cdist_object_base_dir() echo "${__cdist_out_object_dir}/$1" } - __cdist_object_id_from_object() { echo "${1#*/}" @@ -290,19 +284,6 @@ __cdist_remote_type_explorer_dir() ################################################################################ # Traps # -__cdist_tmp_removal() -{ - rm -rf "${__cdist_tmp_dir}" -} - -# Does not work in children, will be called again in every script! -# Use only in interactive "front end" scripts -__cdist_kill_on_interrupt() -{ - __cdist_tmp_removal - kill 0 - exit 1 -} # Remove tempfiles at normal exit trap __cdist_tmp_removal EXIT diff --git a/core/__cdist_kill_on_interrupt b/core/__cdist_kill_on_interrupt new file mode 100644 index 00000000..7cb711fa --- /dev/null +++ b/core/__cdist_kill_on_interrupt @@ -0,0 +1,31 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Run the given command for each created object. +# + +# Does not work in children, will be called again in every script! +# Use only in interactive "front end" scripts +__cdist_kill_on_interrupt() +{ + __cdist_tmp_removal + kill 0 + exit 1 +} diff --git a/core/__cdist_tmp_removal b/core/__cdist_tmp_removal new file mode 100755 index 00000000..74d74936 --- /dev/null +++ b/core/__cdist_tmp_removal @@ -0,0 +1,27 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Remove tmp dir +# + +__cdist_tmp_removal() +{ + rm -rf "${__cdist_tmp_dir}" +}