diff --git a/parse_relay.sh b/parse_relay.sh index 1485f6a..cc853b5 100755 --- a/parse_relay.sh +++ b/parse_relay.sh @@ -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[@]} \ No newline at end of file +echo ${processed_files[@]}