Fix arg ordinals and package sort return.

This commit is contained in:
awalsh128 2022-06-03 21:45:00 -07:00
parent 9568dc9783
commit 49b4515f51

12
lib.sh Normal file → Executable file
View file

@ -1,23 +1,19 @@
#!/bin/bash #!/bin/bash -x
# Sort these packages by name and split on commas. # Sort these packages by name and split on commas.
function normalize_package_list { function normalize_package_list {
stripped="$(echo \"${0}\" | sed 's/,//g')" stripped="$(echo \"${1}\" | sed 's/,//g')"
# Remove extraneous spaces at the middle, beginning, and end. # Remove extraneous spaces at the middle, beginning, and end.
trimmed="$(echo \"${stripped}\" | sed 's/\s\+/ /g; s/^\s\+//g; s/\s\+$//g')" trimmed="$(echo \"${stripped}\" | sed 's/\s\+/ /g; s/^\s\+//g; s/\s\+$//g')"
echo "$(\"${trimmed}\" | sort)" echo "${trimmed}" | sort
} }
# Split fully qualified package into name and version # Split fully qualified package into name and version
function get_package_name_ver { function get_package_name_ver {
IFS=\= read name ver <<< "${0}" IFS=\= read name ver <<< "${1}"
# If version not found in the fully qualified package value. # If version not found in the fully qualified package value.
if test -z "${ver}"; then if test -z "${ver}"; then
ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')" ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')"
fi fi
echo 'package_name="${name}"; package_ver="${ver}"' echo 'package_name="${name}"; package_ver="${ver}"'
} }
function blah {
> /dev/null 2>&1
}