...
 
......@@ -26,6 +26,9 @@ devscripts (2.18.2) UNRELEASED; urgency=medium
also in non-dry-run-mode when verbosity is enabled.
+ s/self.opts/self.args/g
+ Removes also the beginning empty lines of a file
* wnpp-alert:
+ Attempt to add awk commands to pretty print the output of the script.
(Closes: #514307)
-- Pierre-Elliott Bécue <becue@crans.org> Wed, 07 Mar 2018 20:17:05 +0100
......
......@@ -138,5 +138,44 @@ if [ -f "$WNPP_DIFF" ]; then
fi
fi
comm -12 $WNPP_PACKAGES $INSTALLED | sed -e 's/+/\\+/g' | \
xargs -i egrep '^[A-Z]+ [0-9]+ {} ' $WNPP
pretty_print (){
NUM_COLS=3
# Reads the whole input, and measures the max length of each column.
# As we're only interested in the three first columns, we don't bother
# iterating after 3.
#
# Print these lengths at the end.
awk_1='NR > 1 {
cols = '"${NUM_COLS}"';
for (i=1; i<=cols; i++)
{
if (length($i) > max[i])
{
max[i] = (length($i) > max[i] ? length($i) : max[i]);
}
}
}
END {
for (i=1; i<=cols; i++)
printf "%d%s", max[i], (i==cols?RS:FS)
}'
MLS=$(echo "$@"|awk "$awk_1")
# Split on spaces $MLS.
IFS=' ' read -r -a MLS <<< "$MLS"
# Using the lengths we obtained previously, design an awk command
# that includes space padding and 0 padding for the three first columns.
awk_2='{
printf "%-'"${MLS[0]}"'s %0'"${MLS[1]}"'d %'"${MLS[2]}"'s ",$1,$2,$3;
for (i=4; i<=NF; i++)
printf "%s",$i (i==NF?ORS:OFS)
}'
echo "$@" | awk "$awk_2"
}
OUTPUT=$(comm -12 $WNPP_PACKAGES $INSTALLED | sed -e 's/+/\\+/g' | \
xargs -i egrep '^[A-Z]+ [0-9]+ {} ' $WNPP)
pretty_print "$OUTPUT"