I have a number of shell functions that I use in my command line environment and in my shell scripts. I want two of them, upper and lower, to behave differently depending on whether or not data is being piped to them. Both functions are currently written such that they receive input through arguments passed to them.This is the definition of upper:upper () {    my_echo ${1} | tr [:lower:] [:upper:]    return 0}This is the definition of lower:lower () {    my_echo ${1} | tr [:upper:] [:lower:]    return 0}(my_echo is a Python script I wrote as a replacement for echo. It's supposed to output whatever gets passed to it as an argument while converting escape sequences into their literals. I'd be able to print any string without it being interpreted as an option, like -e for echo. The way Unix consoles work threw a wrench into that goal, so I shelved it, so you can just ignore it.)There are several past incarnations of these functions. These are the definitions of the versions that operate on standard input:upper () {    tr [:lower:] [:upper:]}lower () {    tr [:upper:] [:lower:]}If the function being piped to, then it should be operate like the above. If it it isn't, it should read the first parameter.
Detect if stdin is being piped to in shell function
shell