Skip to content

Commit 69c124a

Browse files
committed
tools/semver-compare.sh: rectify printf vs octal numbers (if there are leading zeroes) [networkupstools#3055]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent b3daec3 commit 69c124a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/semver-compare.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ filter_add_extra_width() {
6868
if $NUMERIC && [ x = x"`echo \"$LINE\" | sed 's,[0-9],,g'`" ] ; then
6969
# NOTE: Not all shells have `printf '%0.*d'` (variable width)
7070
# support, so we embed the number into formatting string:
71+
case "$LINE" in
72+
0|1*|2*|3*|4*|5*|6*|7*|8*|9*) ;;
73+
0*) LINE="`echo \"${LINE}\" | sed -e 's/^00*/0/' -e 's/^0*\([1-9]\)/\1/'`" ;;
74+
esac
7175
printf "%0.${NUT_VERSION_EXTRA_WIDTH}d" "${LINE}"
7276
COMPONENTS="`expr ${COMPONENTS} + 1`"
7377
else

0 commit comments

Comments
 (0)