Skip to content

Commit a293247

Browse files
Allow matching certificate by name
1 parent 8bb1760 commit a293247

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/codesign

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ else
2828
error "Unable to find executable \"${target}\""
2929
fi
3030

31-
if [ -z "${selection##[0-9]*}" ]; then
31+
if [[ "${selection}" =~ ^[0-9]+$ ]]; then
3232
certificate="$(echo "${identities}" \
3333
| awk "NR==${selection} {print \$2}")"
3434
else
3535
certificate="$(echo "${identities}" \
36-
| awk 'BEGIN{FS=OFS="\""} {gsub(/ /,"\\ ",$2)} 1' \
37-
| awk "\$3==\"\\\"${selection// /_}\\\"\" {print \$2}")"
36+
| awk 'BEGIN{FS=OFS="\""} {gsub(/ /,"_",$2)} 1' \
37+
| awk "\$3 ~ /${selection// /_}/ {print \$2}")"
3838
fi
3939

4040
if [ -z "${certificate}" ]; then
4141
error "Unable to find codesigning certificate \"${selection}\""
42+
elif [ "$(echo "${certificate}" | wc -l)" -ne 1 ]; then
43+
error "Unable to uniquely identify codesigning certificate \"${selection}\""
4244
fi
4345

4446
command codesign --deep --force --verbose --sign "${certificate}" "${target}"

0 commit comments

Comments
 (0)