RNemeth
RNemeth

Reputation: 43

Find and Execute Scripts in Subdirectories

I have a filesystem structured like this:

Within the init.sh, I have:

#!/bin/bash
set -e

######################
# Run all installers #
######################

cd "$(dirname $0)"/..

# find the installers and run them interatively
find ../ -name install.sh -type f -exec chmod a+x {} \;
find . -name install.sh | while read installer ; do sh -c "${installer}" ; done

This works for the most part, but it is fragile. If one of the install.sh scripts encounters a problem, the init.sh script stops. I'd like for it to continue on to the next install.sh script if this happens. But I'm not sure how to get that to work.

Upvotes: 0

Views: 219

Answers (1)

typecasto
typecasto

Reputation: 176

Replacing sh -c "${installer}" with sh -c "${installer} || true" should work, since true always returns 0.

Upvotes: 1

Related Questions