Avoid infinite recursion in "tree-erase" if there is a circular dependency
This commit is contained in:
parent
ca37fee8d7
commit
6c8095a04f
1 changed files with 10 additions and 4 deletions
|
@ -276,17 +276,23 @@ tree_erase() { #
|
||||||
#--------------#
|
#--------------#
|
||||||
local file=$1
|
local file=$1
|
||||||
local f
|
local f
|
||||||
local -a rootlink
|
local rootlink
|
||||||
local rootlink2
|
local rootlink2
|
||||||
|
|
||||||
#echo file=$file
|
#echo file=$file
|
||||||
rootlink=($(head -n1 $file))
|
rootlink="$(head -n1 $file) "
|
||||||
for f in $(grep '[^0-9 ]' $file | sed 's/.* //'); do
|
for f in $(grep '[^0-9 ]' $file | sed 's/.* //'); do
|
||||||
# echo " f"=$f
|
|
||||||
if [ -f ${f}.dep ]; then
|
if [ -f ${f}.dep ]; then
|
||||||
rootlink2="$(head -n1 ${f}.dep) "
|
rootlink2="$(head -n1 ${f}.dep) "
|
||||||
|
# We want two things:
|
||||||
|
# i) do not erase the file if it is in another branch
|
||||||
|
# ii) do not erase the file if there is a circular dependency
|
||||||
|
# for case i), we test that rootlink is contained in rootlink2
|
||||||
|
# for case ii), we test that rootlink2 is not contained in
|
||||||
|
# rootlink.
|
||||||
# See comment above about srootlink
|
# See comment above about srootlink
|
||||||
if [[ ${rootlink2#"${rootlink[*]} "} != ${rootlink2} ]] ; then
|
if [[ ${rootlink2#${rootlink}} != ${rootlink2} &&
|
||||||
|
${rootlink#${rootlink2}} == ${rootlink} ]] ; then
|
||||||
tree_erase ${f}.dep
|
tree_erase ${f}.dep
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Reference in a new issue