Fix the bug that `parse_relay.sh` doesn't work in Bash.

This commit is contained in:
FrankOu2001 2024-09-12 18:18:58 +08:00
parent ce83223969
commit 08d78d15b4
1 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#!/bin/zsh
#!/bin/bash
## 初始文件名
filename="$1"
@ -16,18 +16,18 @@ find_dependencies() {
processed_files[$1]=$1
# 查找文件中的依赖模块
grep -E '^\s*[a-zA-Z0-9_]+\s+[a-zA-Z0-9_]+\s* \(' "$1" | awk '{print $1}' | uniq | while read -r module; do
while read -r module; do
# 递归查找模块的依赖
if [ -f "${module}.sv" ]; then
find_dependencies "${module}.sv"
elif [ -f "${module}.v" ]; then
find_dependencies "${module}.v"
fi
done
done < <(grep -E '^\s*[a-zA-Z0-9_]+\s+[a-zA-Z0-9_]+\s* \(' "$1" | awk '{print $1}' | uniq)
}
# 开始查找依赖
find_dependencies "$filename"
# 输出所有查找到的文件
echo ${processed_files[@]}
echo ${processed_files[@]}