Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qGfPL-0006kH-3F for pgsql-general@arkaria.postgresql.org; Tue, 04 Jul 2023 12:45:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qGfPK-0000bh-0C for pgsql-general@arkaria.postgresql.org; Tue, 04 Jul 2023 12:45:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qGfPJ-0000bV-J0 for pgsql-general@lists.postgresql.org; Tue, 04 Jul 2023 12:45:25 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qGfPG-001zPT-5I for pgsql-general@lists.postgresql.org; Tue, 04 Jul 2023 12:45:24 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4QwMvd0sFfz9scY; Tue, 4 Jul 2023 14:45:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1688474717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZbBcfKi7Ehoa4boDSSqdkj/SeYWwJ1DafEhdfB+t7c=; b=jNeaQAF7v6Magxx9k/x3wmGBKLdiiWdRvbiQ37r63FFUzzE/fu+O2Z1A472F9jCWrEPDoy 5E5+8WPXXzj97q/aLgX1ljJkSbF1r2RgpDMQbrCF04JERKb8mzS20LGIEV3LZgxxsZdfS6 61laEHXxYYXnCObjUcGY6fUs3JBZWV61eWGQ3s75KKKqlqmOSbmg5OR6Uj2gFUET7Y3g4N Tn8qGoUnZ9tI8BoW41i7K3hvVVTfgpj5F3laRdTn+THIzHha63X1Yqf4RxEsaFlgT1DEcq hFJMRu6VKcce1denOwMXC0XwesqaQjUmIdTUdje8UazuSHuS3kv7UgDH4IGYYg== Date: Tue, 4 Jul 2023 14:45:16 +0200 (CEST) From: Erik Wienhold To: jian he , pgsql-general list Message-ID: <1823426797.696934.1688474716571@office.mailbox.org> In-Reply-To: References: Subject: Re: psql -c command parse "select $$hello$$" failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4QwMvd0sFfz9scY List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 04/07/2023 14:21 CEST jian he 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