#!/bin/bash

CountLineStdin() {
  if [ ! -p /dev/stdin ]; then
    echo "stdin empty!"
    return 1
  fi
  i=0
  while read line
  do
    i=`expr $i + 1`
    echo "inside: $i"
  done < <(cat -)
  return 0
}
CountLineStdin
echo "outside: $i"
