On Mon, 9 Dec 2013, canito at dalan.us wrote:

> grep --version
> GNU grep 2.6.3
>
> Pretty weird. I'll just assume user error.
>
> cat param.sh
> #!/bin/bash
> set -x
>
> echo $1
> FUNC=$1
>
> grep -Eic -- "$FUNC"
>
> ./param.sh --test
>
> + echo --test
> --test
>
> + FUNC=--test
>
> + grep -Eic -- --test
> ^C
>
> It just hangs, which is weird. I was under the impression that one could 
> grep variables.


It hangs because grep has no input.  You need to pump some data into it, 
or add another argument for a filename.  Try this:

echo -e "--test\na\nb\n--test\n--tested" | ./param.sh --test

That should return "3" (without the quotes!).

Mike