Forward-slash-enclosed Bash script function name(?)

What is this???

/[*]/ {
      inFoo = ($1 == "["foo"]")
      next
    }

It looks like a function because of the enclosing braces, but what on earth is that before the opening brace??? Some sort of regex’ed function name? I’ve never been great at Bash scripting, but this is altogether indecipherable.

There’s a similar one, but it’s body is too large (and potentially sensitive) for me to post:

/.*/ {
    ...
    }

Answer

Are you certain that you posted bash code? It looks to me like part of an awk script. If it is awk code, then the forward slashes delimit a regex address rule, ie. process the {...} for all lines matching the regex. The rule matches all lines that have an open bracket, followed by some text, followed by a close bracket.

Leave a Reply

Your email address will not be published. Required fields are marked *