Skip to content

Commit

Permalink
Fix '\%o' for printf from coreutils
Browse files Browse the repository at this point in the history
The printf utility provided by coreutils when interpreting '\%o' format
does not recognize %o as formatting directive. For example
printf '\%o 0 returns \%o and warning: ignoring excess arguments,
starting with ‘0’, which results in failed tests in
t5309-pack-delta-cycles.sh. In most shells the test ends with success as
the printf is a builtin utility.

Fix it by using '\\%o' which is interpreted consistently in all versions
of printf.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Kacper Kornet authored and Junio C Hamano committed Oct 31, 2013
1 parent 16c159d commit fbc812a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions t/lib-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# Print the big-endian 4-byte octal representation of $1
uint32_octal () {
n=$1
printf '\%o' $(($n / 16777216)); n=$((n % 16777216))
printf '\%o' $(($n / 65536)); n=$((n % 65536))
printf '\%o' $(($n / 256)); n=$((n % 256))
printf '\%o' $(($n ));
printf '\\%o' $(($n / 16777216)); n=$((n % 16777216))
printf '\\%o' $(($n / 65536)); n=$((n % 65536))
printf '\\%o' $(($n / 256)); n=$((n % 256))
printf '\\%o' $(($n ));
}

# Print the big-endian 4-byte binary representation of $1
Expand Down

0 comments on commit fbc812a

Please sign in to comment.