#!/usr/bin/bash
set -euo pipefail

# Script to detect package ownership of a file in a Linux system.
# Required environment setup for consistent output
export LC_ALL=C
export LANG=C

# Usage: ./query-file-owner [FILE] [FILE...]
if [ "$#" -eq 0 ]; then
    echo "Usage: $0 [FILE] [FILE...]" >&2
    exit 1
fi

for FILE in "$@"; do
    # Use your package manager to find the package that owns the file
    # Package Manager should return two space-separated values: NAME and VERSION
    rpm -q --qf '%{NAME} %{EVR}\n' -f "$FILE"
done
    
