[BASH] recognise new line regex in case statement

Hi,

I'm trying to write a routine to parse a file that contains data that will be read
into arrays. The file is composed of labels to identify data types and arbitrary
lines of data with the usual remarks and empty new lines as is common with
config files.

The initial pass is built as so:

while read line; do 
	case $line in
	'\n'	)	continue;;
	'#'*	)	continue;;
	'['*']'	)	do_label;;
	*	)	do_error;;
	esac
done < $filename

Unfortunately, I seem to be having a problem trying to get the case statement to
recognise a new line, falling through to default. After searching, I was left
unenlightened. I tried inserting '^' and '$' before and after, inside and outside '\n'
but still no success. I also tried using '\f' and '\r' just in case it was a text editor
misinterpretation.

However, I did find alternative command line solutions, but I would prefer to keep
it purely bash and regex if possible.

Feedback would be appreciated.

A.

when the line of the file only contains new line the variable strin length is 0

while read line; do 
    case $line in
#   '\n'    )    continue;;
    '#'*    )    continue;;
    '['*']'    )    do_label;;
    *    )    if [ "$line" ]
               then
                  do_error
                else
                    continue
                fi
                ;;
    esac
done < $filename

Hi ASGR,

You can use "" for an empty line:

while read line; do
  case $line in
    ""|\#* ) : ;;
    \[*\]  ) do_label;;
    *      ) do_error;;
  esac
done < $filename

S.

I don't believe it ! (expression confirming that it works)

Thanks for your help.

A.