Not implicitly, but
{ echo some_file; cat some_file; } | function | ...
with
function () {
read filename
while read data; do
grep "string" $filename | ...
done
}
should do what you want.
If standard input is connected directly to a file, you might be able to use readlink
on a file such as /proc/self/fd/0
(in Linux) to get the name of the file opened on standard input. However, standard input may come from a pipe, which may come from an arbitrary program writing directly to the pipe, rather than an actual file.