I am trying to write a shell script which will take various non-human readable files and convert them to something human readable.
I have the following code
#!/usr/bin/sh
# Used to convert annoying files to plaintext
case $1 in
  *.pdf) 
    tmp_file=$(mktemp);
    pdftotext "$1" "$tmp_file";
    echo "$tmp_file";
    ;;
  *) 
    echo "$1";
    ;;
esac
When I run this like totext some.pdf I get a temporary file printed as expected and running cat on said file gives me the expected text.
However, when I do totext some.pdf | cat I still get the temporary file printed and I do not see its contents.
How do I make the script have it's arguments be taken up by the pipe and passed to the next program. In this case, cat.
