Re: backslashes in pgindent

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Luke Lonergan <llonergan(at)greenplum(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: backslashes in pgindent
Date: 2005-07-16 04:59:16
Message-ID: 200507160459.j6G4xGq24356@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Luke Lonergan wrote:
> Bruce,
> > I found that parentheses in gawk regular expressions require backslashes
> > so they are not treated as regex groupings:
> >
> > $ echo '('|awk '$0 ~ /(/ {print $0}'
> > awk: cmd. line:1: fatal: Unmatched ( or \(: /(/
> > $ echo '('|awk '$0 ~ /\(/ {print $0}'
> > (
>
>
> > Now, it seems closing parentheses are OK because there is no open group,
> > but I think I should use backslashes there too:
> >
> > $ echo ')'|awk '$0 ~ /)/ {print $0}'
> > )
> > $ echo ')'|awk '$0 ~ /\)/ {print $0}'
> >
> > Does your awk produce different results? What version is it? Mine is GNU Awk
> > 3.0.6.
>
> Yes - on the last test, mine emits the ")" and yours apparently does not.
> The version I ran with is 3.1.4.

Actually, mine returns ')' too for the last command. I didn't copy
that into the email. How about the top tests? Notice I get an error on
the first one without the backslash. Are you OK escaping '(' but not
')'? That might be a solution.

> The escaped parenthesis in the unpatched pgindent causes the following
> warning:
>
> $ pgindent test.c
> Hope you installed /src/tools/pgindent/indent.bsd.patch.
> awk: cmd. line:12: warning: escape sequence `\)' treated as plain `)'
>
> Which implies an unnecessary escaping, which appears to function correctly
> without the escape.
>
> Cheers,
>
> - Luke
>
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Luke Lonergan 2005-07-16 05:34:35 Re: backslashes in pgindent
Previous Message Luke Lonergan 2005-07-16 04:45:05 Re: backslashes in pgindent