From 29e029a2ebd60084eb447561509a249e15fdd888 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Jun 2011 14:37:36 +0200 Subject: [PATCH] replace __cdist_type_has_explorer with __cdist_dir_listing Signed-off-by: Nico Schottelius --- bin/cdist-config | 9 --------- core/__cdist_dir_listing | 30 ++++++++++++++++++++++++++++++ core/__cdist_object_explorer_run | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100755 core/__cdist_dir_listing diff --git a/bin/cdist-config b/bin/cdist-config index a8f32dc1..bed9e6b4 100644 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -330,15 +330,6 @@ __cdist_type_from_object() echo "${1%%/*}" } -__cdist_type_has_explorer() -{ - # We only create output, if there's at least one explorer - # and can thus be used as a boolean ;-) - if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then - ls -1 "$(__cdist_type_explorer_dir "$1")" - fi -} - __cdist_type_explorer_pushed() { [ -f "${__cdist_out_type_dir}/${__cdist_name_type_explorer_pushed}" ] \ diff --git a/core/__cdist_dir_listing b/core/__cdist_dir_listing new file mode 100755 index 00000000..f4aa2320 --- /dev/null +++ b/core/__cdist_dir_listing @@ -0,0 +1,30 @@ +#!/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 . +# +# +# List files in a directory, if it exists +# +# We only create output, if there's at least one entry +# and can thus be used as a boolean ;-) +# + +__cdist_dir_listing() +{ + [ -d "$1" ] && ls -1 "$1" +} diff --git a/core/__cdist_object_explorer_run b/core/__cdist_object_explorer_run index eb62401e..45ca3379 100755 --- a/core/__cdist_object_explorer_run +++ b/core/__cdist_object_explorer_run @@ -30,7 +30,7 @@ __cdist_object_explorer_run() __cdist_type="$(__cdist_type_from_object "$__cdist_object_self")" # Check if type of object has >= 1 explorer - __cdist_has_explorer="$(__cdist_type_has_explorer "$__cdist_type")" + __cdist_has_explorer="$(__cdist_dir_listing "$(__cdist_type_explorer_dir "$__cdist_type")")" # Run the type explorers for the current object if any if [ "$__cdist_has_explorer" ]; then if ! __cdist_type_explorer_pushed "$__cdist_type"; then