On Wed, Jan 11, 2017 at 11:46:38AM +0100, Andrew Jones wrote:
[...]
> > So, how about this:
> >
> > rm -rf $unittest_log_dir.old || err "Failed remove old logs"
> > if [[ -d $unittest_log_dir ]]; then
>
> Only [ ... ] for tests like these
I thought [[ ... ]] would be superior to [ ... ] if we are not
considering the POSIX compatibility issue?
Hmm, after a quick grep, I see that kvm-unit-tests repo is using [[
... ]] only if doing any kind of pattern/regex matching, right? If so,
I'll just follow. ;-)
>
> > mv $unittest_log_dir $unittest_log_dir.old ||
> > err "Failed backup logs"
> > fi
> > mkdir $unittest_log_dir || err "Failed to create log dir"
> >
> > And define err() in common.bash:
> >
> > function err()
> > {
> > echo "$@"
> > exit 1
> > }
>
> The above is mostly just translating rm/mv/mkdir stderr messages to
> new messages. We can do it much more simply like
>
> rm -rf logs.old
> [ -d logs ] && mv logs logs.old
> mkdir logs || exit 2
Okay I'll use this. Thanks!
-- peterx