ocehb: (Default)
ocehb ([personal profile] ocehb) wrote2018-03-08 08:05 pm
Entry tags:

Множественное определение функций

В zsh можно определить несколько функций за раз,

разница будет только в $0:

# function sha1 sha224 sha256 sha384 sha512 () {
  local cmd="${0}sum"
  if [[ $# == 0 ]]; then
    cat
  else
    print -n "$@"
  fi | $cmd | cut -d" " -f1
}
# for hash in sha1 sha224 sha256 sha384 sha512; do
  res=$( $hash test )
  print -f "%-6.6s %3d %s\\n" $hash $#res $res
done
sha1    40 a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
sha224  56 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809
sha256  64 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
sha384  96 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
sha512 128 ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff


Печать таблицы хешей по именам.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org