From 3b9e295a377a0e0c704803aedb18c6caedb2b4e6 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 21 Jan 2019 17:16:53 +0000 Subject: [PATCH] Use find instead of ls for determining dir emptiness ls foo/* isn't a great way to do this - but find, as is usually the case, solves all problems. Change-Id: Ic30b36ccee41e9b74e187eb3cdab0359f659a1c9 --- roles/merge-output-to-logs/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/merge-output-to-logs/tasks/main.yaml b/roles/merge-output-to-logs/tasks/main.yaml index a4fe8eb4d..504c87ab4 100644 --- a/roles/merge-output-to-logs/tasks/main.yaml +++ b/roles/merge-output-to-logs/tasks/main.yaml @@ -2,7 +2,7 @@ when: zuul.change is defined delegate_to: localhost shell: | - if [ -n $(ls {{ zuul.executor.work_root }}/{{ item }}) ] ; then + if [ -n "$(find {{ zuul.executor.work_root }}/{{ item }} -mindepth 1)" ] ; then # Only create target directory if it is needed. # Do not fail if it is already there. mkdir -p {{ zuul.executor.log_root }}/{{ item }}