Reuse content of fd multiple times

Working with big ascii files that I keep compressed on disk. (ie, bigfile.json.gz )

Clever me thought “hey, let’s use process substitution to work with the uncompressed content of the file”.

Imagine a simple function that takes a file as input like so:

func_stat() {
  wc -l $1  #Counts nb of lines
  wc -c $1  #Counts its size
}

Works perfectly using a regular file:

func_stat bigfile.json
408432 bigfile.json
17986889 bigfile.json

BUT it fails using <() syntax:

func_stat <(gzip -dc bigfile.json.gz)
408432 /dev/fd/63
0 /dev/fd/63

the 1st ‘wc -l’ within the function could read the fd just fine. But the 2nd ‘wc -c’ doesn’t work.

Now, is there a way we can get more control how FDs get closed ?