Pro/Engineer: Individuare dove è montato un componente in base al codice dentro gli assembly

Ho realizzato uno Bash Script il cui scopo è quello, fornendo il codice di un componente, individuare in quali assiemi è montato e mostrare le dipendenze degli stessi.

E’ utile per coloro che, come me, devono operare senza Pro/Intralink; lo script, su Windows, può essere eseguito tramite MSYS.

Questo è il sorgente dello script:

#!/bin/bash

# Questo script serve per individuare, all'interno degli assembly, il
# codice specificato.

################################################################################
#_______________________________________________________________________________
max_level=32

################################################################################
#_______________________________________________________________________________
[ "${1}" == "" ] && printf '\nERRORE: Devi specificare il pattern di ricerca.\n' && exit 1;

################################################################################
#_______________________________________________________________________________
pattern_matching_path_db=$(echo "/tmp/PROE_find_${1}.dat" | sed 's@[^a-zA-Z0-9._/-]@_@g')

################################################################################
#_______________________________________________________________________________
matches=$(grep -iF "${1}" *.asm.* | sed 's@Binary file @@' | sed 's@ matches@:@' | awk -F':' '{print $1}' | sed 's@\.[0-9]*$@@' | sort | uniq)
level=$((${2:-0} + 2))

################################################################################
#_______________________________________________________________________________
if [ ${level:-0} -le 2 ]; then
    rm -f "${pattern_matching_path_db}"
fi

################################################################################
#_______________________________________________________________________________
for match in ${matches}; do
    sub_match=$(echo "${match}" | sed 's@\.\(asm\|prt\|drw\)\(\.[0-9]*\)\?$@@')
    find_match=$(echo "${1}" | grep -iF "${sub_match}")

    [ "${find_match}" == "" ] && printf "%${level}s |_ %s\n" " " "${match}"
    if [ ${level:-0} -le ${max_level:-16} ]; then
	is_loop=$([ -f "${pattern_matching_path_db}" ] && grep -Fi " ${match} " "${pattern_matching_path_db}")
	echo " ${match} " >> "${pattern_matching_path_db}"

	[ "${is_loop}" == "" ] && [ "${find_match}" == "" ] && $0 "${sub_match}" ${level}
    else
	printf "%${level}s |_ %s\n" " " "[${match}]"
    fi
done

################################################################################
#______________________________________________________________________________
if [ ${level:-0} -le 2 ]; then
    rm -f "${pattern_matching_path_db}"
fi

################################################################################
#_______________________________________________________________________________