Created
June 20, 2019 05:24
-
-
Save lebensterben/63700364b55eb11e1ec0439acf411b42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- 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