Files
Daniele Fucini bd8ded486d Add bats test suite
Black-box tests that run the script with stub commands on a minimal PATH and temp config/state folders.
2026-11-09 19:51:42 +01:00

14 lines
477 B
Bash
Executable File

#!/bin/bash
# "pacman -Q <pkg>": looks the package up in $STUB_DATA/installed ("name version" lines).
[[ ${1:-} == -Q && $# == 2 ]] || { echo "pacman stub: unsupported arguments: $*" >&2; exit 1; }
if [[ -f $STUB_DATA/installed ]]; then
while read -r name ver; do
if [[ $name == "$2" ]]; then
printf '%s %s\n' "$name" "$ver"
exit 0
fi
done < "$STUB_DATA/installed"
fi
printf "error: package '%s' was not found\n" "$2" >&2
exit 1