summary refs log tree commit diff
path: root/Functions/VCS_Info/VCS_INFO_hexdump
blob: 11f1c1a506ddd9ebf016e4fd08290a2e65d87845 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## vim:ft=zsh

# VCS_INFO_hexdump FILENAME BYTECOUNT
#
# Return in $REPLY a hexadecimal representation (lowercase, no whitespace)
# of the first BYTECOUNT bytes of FILENAME.

if [[ -r $1 ]]; then
  setopt localoptions nomultibyte extendedglob
  local val
  read -k $2 -u 0 val <$1
  REPLY=${(Lj::)${(l:2::0:)${(@s//)val}//(#m)*/$(( [##16] ##$MATCH ))}}
else
  return 1
fi