Skip to content

Instantly share code, notes, and snippets.

@lebensterben
Created June 20, 2019 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lebensterben/63700364b55eb11e1ec0439acf411b42 to your computer and use it in GitHub Desktop.
Save lebensterben/63700364b55eb11e1ec0439acf411b42 to your computer and use it in GitHub Desktop.
#-*- mode: shell-script -*-
# list files included in a list of bundle
#swupd-list () {
emulate -RL zsh
setopt extendedglob
local myname usage opts file i
local -a output
local OPTARG OPTIND
myname=${(%):-%N}
read -r -d '' usage <<EOT
Usage:
$myname [-o OUTPUTFILE] BUNDLE [BUNDLE2 ...]
List files installed by bundles specified by the user.
EOT
while getopts ":o:" opts; do
case "${opts}" in
o )
file=${OPTARG}
(
set -e
[[ ! -a $file ]] && touch ${file}
)
;;
\? )
print "Invalid option: $OPTARG"
print $usage
return 1;;
: )
print "Invalid option: Option $OPTARG requires an argument"
print $usage
return 1;;
esac
done
shift $((OPTIND -1))
for i in $@; do
if [ ! -r /usr/share/clear/allbundles/"$i" ]; then
echo "Bundle Doesn't Exist: $1"
else
output+="$(cat /usr/share/clear/allbundles/$1 | jq --raw-output '.Files | keys[]')"
fi
done
if [ -n "$file" ]; then
cat <<< $output | sort | uniq > $file
else
cat <<< $output | sort | uniq | less
fi
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment