From 50335b5d67f14aac3e7794f448e85ecc65cfca1c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 20 Jun 2020 04:19:08 -0600 Subject: [PATCH] allow filter directory via shell wildcards --- sri | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sri b/sri index 053cc71..57a68b2 100755 --- a/sri +++ b/sri @@ -107,6 +107,14 @@ while [ $# -gt 0 ]; do fi shift ;; + --filter) + if [ -z "$2" ]; then + displayError 1 'Filter cannot be blank.' + else + filter="$2" + fi + shift + ;; *) # unknown option printf "\n%sUnknown option: %s.\n" "$err" "$1" @@ -120,7 +128,7 @@ printf "\n" ### do SRI generation if [ "$doDir" -eq 1 ]; then - for file in "$hashDir"/*; do + for file in "$hashDir"/${filter}; do hash=$( openssl dgst -${algo} -binary "$file" | openssl base64 -A) > /dev/null 2>&1 if [ -z "$hash" ]; then printf "%s --> unable to generate SRI hash\n" "$file"