I want to write the following bash function in a way that it can accept its input from either an argument or a pipe:b64decode() {    echo $1 | base64 --decode; echo}Desired usage:$ b64decode QWxhZGRpbjpvcGVuIHNlc2FtZQ=$ b64decode < file.txt$ b64decode <<< QWxhZGRpbjpvcGVuIHNlc2FtZQ=$ echo QWxhZGRpbjpvcGVuIHNlc2FtZQ= | b64decode
Bash function that accepts input from parameter or pipe
bash;pipe;function;stdin
You can use /dev/stdin to read from standard inputb64decode(){    if (( $# == 0 )) ; then        base64 --decode < /dev/stdin        echo    else        base64 --decode <<< $1        echo    fi}$# == 0 checks if number of command line arguments is zerobase64 --decode <<< $1 one can also use herestring instead of using echo and piping to base64 