Skip to content

Commit

Permalink
v0.3.1 - new table list size fix, was ignoring first package when pri…
Browse files Browse the repository at this point in the history
…nting. Actual update was fine.
  • Loading branch information
tavinus committed Dec 10, 2018
1 parent d2385c4 commit c5eda9b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions opkg-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


### Initialization
OPKGUPVERSION="0.3.0"
OPKGUPVERSION="0.3.1"
OPKGBIN="$(which opkg 2>/dev/null)"
SSMTPBIN="$(which ssmtp 2>/dev/null)"
BANNERSTRING="Simple OPKG Updater v$OPKGUPVERSION"
Expand Down Expand Up @@ -136,7 +136,7 @@ list_upgrades() {
prettyPrintPacks() {
echo -ne "$PACKS" | awk '
function rep(c, n){ s=sprintf("%" n "s",""); gsub(/ /,c,s); return s }
BEGIN{ j=1; } NR>1{
BEGIN{ j=1; } NR>0{
l[j, 1]=($1);
l[j, 2]=($3);
l[j++, 3]=($5);
Expand All @@ -149,7 +149,7 @@ max[3]=(max[3]>=7?max[3]:7);
}
function div(){ printf "+-----+%s+%s+%s+\n", rep("-", max[1]+2), rep("-", max[2]+2), rep("-", max[3]+2) }
function head() { printf "| %3s | %-" max[1] "s | %-" max[2] "s | %-" max[3] "s |\n", "#", "Package", "Current", "Update" }
END {div() ; head() ; div() ; for (i=1; i<NR; i++) printf "| %3d | %-" max[1] "s | %-" max[2] "s | %-" max[3] "s |\n", i, l[i, 1], l[i, 2], l[i, 3]; div()}'
END {div() ; head() ; div() ; for (i=1; i<=NR; i++) printf "| %3d | %-" max[1] "s | %-" max[2] "s | %-" max[3] "s |\n", i, l[i, 1], l[i, 2], l[i, 3]; div()}'
}

### Parse CLI options
Expand Down Expand Up @@ -314,7 +314,6 @@ opkg_upgradable() {
#PACKS="$(cat pkg-example.txt)" # testing
if ! is_empty "$PACKS"; then
PACKS_NAMES="$(echo -ne "$PACKS" | awk '{ printf "%s ", $1 }')"
PACKS_COLS="$(echo -ne "$PACKS" | awk 'NR>1{for (i=1; i<=NF; i=i+2) max[i]=(length($i)>max[i]?length($i):max[i])} END {for (i=1; i<=NF; i=i+2) printf "%d ", max[i]}')"
#echo -ne "$PACKS" | awk '{ printf "pack: %s from: %s to: %s \n", $1, $3, $5 }'
PACKS_COUNT="$(echo "$PACKS" | wc -l)"
fi
Expand Down

0 comments on commit c5eda9b

Please sign in to comment.