Skip to main content
added 1 character in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

As dhag points out, you are recursively calling youyour function.

He rightly suggests you drop the backslashes and use command instead.

Additionally, the curly braces are not needed (but are allowed).

This is what my function would look like:

sha256sum () {
    if [ -n "$1" ]; then
        pv "$1" | command sha256sum -
    else
        command sha256sum --help
    fi
}

A downside of this shell function is that you can't pass command line flags to sha256sum, or multiple input files.

As dhag points out, you are recursively calling you function.

He rightly suggests you drop the backslashes and use command instead.

Additionally, the curly braces are not needed (but are allowed).

This is what my function would look like:

sha256sum () {
    if [ -n "$1" ]; then
        pv "$1" | command sha256sum -
    else
        command sha256sum --help
    fi
}

A downside of this shell function is that you can't pass command line flags to sha256sum, or multiple input files.

As dhag points out, you are recursively calling your function.

He rightly suggests you drop the backslashes and use command instead.

Additionally, the curly braces are not needed (but are allowed).

This is what my function would look like:

sha256sum () {
    if [ -n "$1" ]; then
        pv "$1" | command sha256sum -
    else
        command sha256sum --help
    fi
}

A downside of this shell function is that you can't pass command line flags to sha256sum, or multiple input files.

Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

As dhag points out, you are recursively calling you function.

He rightly suggests you drop the backslashes and use command instead.

Additionally, the curly braces are not needed (but are allowed).

This is what my function would look like:

sha256sum () {
    if [ -n "$1" ]; then
        pv "$1" | command sha256sum -
    else
        command sha256sum --help
    fi
}

A downside of this shell function is that you can't pass command line flags to sha256sum, or multiple input files.