#!/bin/sh repodir=$1 pattern="*.pkg.tar.zst" # Combine directory and pattern. # Quote the directory to handle spaces, leave pattern unquoted for expansion. for pkgfile in "$repodir"/$pattern; do # CRITICAL: Check if file exists. # If no files match, 'sh' returns the literal string (e.g., /dir/*.txt) if [ -e "$pkgfile" ]; then echo "Signing $pkgfile" gpg --use-agent --output "${pkgfile}".sig --detach-sig "${pkgfile}" fi done