Fix fmt-image-match.sh

This commit is contained in:
Shiming Zhang 2024-08-01 15:52:11 +08:00
parent 863d1bbf64
commit 5f93c102a7
1 changed files with 20 additions and 4 deletions

View File

@ -4,11 +4,11 @@ function check_match() {
local image=$1
local lines=$2
for line in ${lines}; do
if [[ "${line}" == *"**" ]]; then
if [[ "${line}" == *"/**" ]]; then
if [[ "${image}" == "${line%\*\*}"* ]]; then
return
fi
elif [[ "${line}" == *"*" ]]; then
elif [[ "${line}" == *"/*" ]]; then
if [[ "${image}" == "${line%\*}"* ]]; then
if [[ "${image#"${line%\*}"}" != *"/"* ]]; then
return
@ -20,6 +20,20 @@ function check_match() {
echo "${image}"
}
function check_match_more() {
local image=$1
local lines=$2
for line in ${lines}; do
if [[ "${line}" == *"/**" ]]; then
if [[ "${image}" == "${line%\*\*}"* ]]; then
return
fi
fi
done
echo "${image}"
}
function format() {
local file=$1
local lines="$(cat "${file}")"
@ -30,8 +44,10 @@ function format() {
done
for line in ${lines}; do
if [[ "${line}" == *"*" ]]; then
echo ${line}
if [[ "${line}" == *"/**" ]]; then
echo "${line}"
elif [[ "${line}" == *"/*" ]]; then
check_match_more "${line}" "${lines}"
fi
done
}