Add file tracking status query function

This commit is contained in:
Juno Takano 2024-09-13 21:57:31 -03:00
parent 67de45f5ba
commit 5f650f7d17

View file

@ -1,8 +1,26 @@
# functions to track, untrack and query tracked state of packages
# returns 0 if all packages are tracked, 1 if any is untracked
query_packages() {
local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
if ! cat "$CONFIG_ROOT/packages" | grep -q "^$package$"; then
return 1
fi
return 0
done
}
track_packages() { track_packages() {
local packages="$1" local packages="$1"
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
if query_packages "$package"; then
log info "Package $package was not tracked because it is already tracked"
else
echo "$package" >> "$CONFIG_ROOT/packages" echo "$package" >> "$CONFIG_ROOT/packages"
fi
done done
} }