From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: psql -c command parse "select $$hello$$" failed |
Date: | 2023-07-04 12:45:16 |
Message-ID: | 1823426797.696934.1688474716571@office.mailbox.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 04/07/2023 14:21 CEST jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> not sure this is the expected result.
>
> /home/jian/postgres/pg16_test/bin/psql -d test_dev -p 5455 -c "select $$hello$$"
> 2023-07-04 20:15:51.066 CST [1562050] ERROR: trailing junk after
> numeric literal at or near "884070h" at character 8
> 2023-07-04 20:15:51.066 CST [1562050] STATEMENT: select 884070hello884070
> ERROR: trailing junk after numeric literal at or near "884070h"
> LINE 1: select 884070hello884070
The error is expected because the shell replaces $$ with its process ID inside
double quoted strings. Check out Bash quoting [1] (assuming that you use bash
but this applies to every(?) shell).
Either use single quotes around the statement or escape every $ with \$:
psql -c 'select $$hello$$'
psql -c "select \$\$hello\$\$\"
[1] https://www.gnu.org/software/bash/manual/bash.html#Quoting
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Lorusso Domenico | 2023-07-05 12:23:44 | Strange behaviour on function |
Previous Message | Julien Rouhaud | 2023-07-04 12:36:16 | Re: psql -c command parse "select $$hello$$" failed |