Skip to content

Commit

Permalink
[.cleanup_gmx_analyses.sh]: Increase Robustness
Browse files Browse the repository at this point in the history
* Make function variables local to the function scope.
* Improve glob patterns.
  • Loading branch information
andthum committed Jul 12, 2023
1 parent 656d530 commit 7c93543
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions analysis/lintf2_ether/gmx/.cleanup_gmx_analyses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

gather() {
# Gather output of similar analyses scripts.
root="${1}"
local root="${1}"
if [[ -d ${root} ]]; then
echo "WARNING: Directory already exists: '${root}'"
return 0
fi
if [[ -n $(find . -maxdepth 1 -type d -name "${root}_*slurm-[0-9]*" -print -quit) ]]; then
if [[ -n $(find . -maxdepth 1 -type d -name "${root}*_slurm-[0-9]*" -print -quit) ]]; then
mkdir "${root}/" || exit
mv "${root}"_*slurm-[0-9]*/ "${root}/" || exit
mv "${root}"*_slurm-[0-9]*/ "${root}/" || exit
cd "${root}/" || exit
mv "${root}"_*slurm-[0-9]*/* ./ || exit
rm -r "${root:?}"_*slurm-[0-9]*/ || exit
mv "${root}"*_slurm-[0-9]*/* ./ || exit
rm -r "${root:?}"*_slurm-[0-9]*/ || exit
cd ../ || exit
else
echo "WARNING: No directory matching pattern '${root}_*slurm-[0-9]*'"
echo "WARNING: No directory matching pattern '${root}*_slurm-[0-9]*'"
fi
}

Expand Down

0 comments on commit 7c93543

Please sign in to comment.