Use tail -n 1 instead of tail -1.

The old way is deprecated and not in POSIX.
Avoid "local generic_filter=".

Combining initialization with "local" is a portability
problem if I remember correctly (local isn't POSIX anyway).

generic_filter is always initialized later so there
is no need to initialize it to empty here.
Use the generic_filter variable.

It was set but unused. This caused a bug for push mode.