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" filename="$1"
@ -16,14 +16,14 @@ find_dependencies() {
processed_files[$1]=$1 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 if [ -f "${module}.sv" ]; then
find_dependencies "${module}.sv" find_dependencies "${module}.sv"
elif [ -f "${module}.v" ]; then elif [ -f "${module}.v" ]; then
find_dependencies "${module}.v" find_dependencies "${module}.v"
fi fi
done done < <(grep -E '^\s*[a-zA-Z0-9_]+\s+[a-zA-Z0-9_]+\s* \(' "$1" | awk '{print $1}' | uniq)
} }
# 开始查找依赖 # 开始查找依赖