Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tA9MP-00E0ao-2b for pgsql-general@arkaria.postgresql.org; Sun, 10 Nov 2024 14:56:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tA9ML-007A18-QN for pgsql-general@arkaria.postgresql.org; Sun, 10 Nov 2024 14:56:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tA9ML-007A10-FI for pgsql-general@lists.postgresql.org; Sun, 10 Nov 2024 14:56:14 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tA9MI-001D2V-Ng for pgsql-general@lists.postgresql.org; Sun, 10 Nov 2024 14:56:13 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-83ab21c269eso144103539f.2 for ; Sun, 10 Nov 2024 06:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731250570; x=1731855370; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=T9JVYKtoq26y21H0AFR/kR9e2RW2XgugUkxkeXG5LtA=; b=dLK3QiII2GLWbU/AIsteW927J19PHI9xZIxr/jj2QdO/UCUOkzh0WRb6BNsREFYrmp Vofs+AdbyWkazhgjeoweDMG8moy0cKYxf7Ug7NyJkVEgzNxNMrrTOag3f4UhQQnVnVap Dw7yEQ5tamR/vP9y2CvxfwTT/0EQ91dhxmBwZGzCL31vmTyag5TOae+uMTlVQrZUqPdI anzDcBKVp82OD+WAbkwBZVIT1DVbP9A1YtzQjvyGJXv3dZO6QWfkPJsvXAozah+eXt7N KbOlNY48hGANOuwCPwNQibLDoMbXozwS90EAUUFNWH2gltiyIXWZODAsjDWYUbgLorka 1HKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731250570; x=1731855370; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T9JVYKtoq26y21H0AFR/kR9e2RW2XgugUkxkeXG5LtA=; b=RLUQr3l8XuOX8l1TBSFhDEVue9jGj0wJF7qklEATMyj2+T+Fv9zHoSNn1BDMeMD89P K9PkZ4uySrPS7xLCQGc/NAglkBAeO/Y9LDQJwv8ruiVQ/P1EaToj0O4C35q5LJFBIxTl NjjnERlRnHehRhKILjtfLmCxArSadd4D5t4WAE7wyKhTv5GK6HFHoIcEXdg3PfAnf87S a68qFOAvX2TBT+NG6FrHDHYeGmW+9xGnjxig31zLXER4AxvSSpzN1x2VKICLdDXJ8EN3 Te09q+hUOAqgN9x652iw/CNhtcUMq1g1zgih6G3yI+H5SuAXwIXnoD5ESEQjG0149ujh Zu4A== X-Gm-Message-State: AOJu0YyfxVYeLyYs5xvo8erleToLrgBMQNtZe86EEwlHVMckA8XIO7os xebWZgQozuXv4SI7A2Jod6H3JuKVGMm2kMa6uZi5+ZT2FEcMLpyU9oiuIYa2j7BA1J+Y6Oit0hh koJnl9YaDWsDDJz/3XFt059KHBRA= X-Google-Smtp-Source: AGHT+IGGN7j6th2Uv69odg2iS3LO78vODqtAhhx6epLuoD/Nc0xkT4tMPab23KRJ0t7gdIU0xeUzkZTbd/9cqIAXVNc= X-Received: by 2002:a05:6e02:1485:b0:3a3:a307:6851 with SMTP id e9e14a558f8ab-3a6f1a504fcmr102236075ab.22.1731250569801; Sun, 10 Nov 2024 06:56:09 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Sun, 10 Nov 2024 09:55:34 -0500 Message-ID: Subject: Re: Bash function from psql (v14) To: Murthy Nunna Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000003af8ac0626902f24" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003af8ac0626902f24 Content-Type: text/plain; charset="UTF-8" What problem are you trying to solve? If you tell us that, we can guide you to some better solutions. There are numerous issues here, but the most important are: 1) Calling a shell via \! invokes an entirely new process: there is no link to the parent or grandparent process 2) The run-bash-function must be declared before being called, so that bash code was never going to work anyway. In other words, this is valid: run-bash-function() { echo "Here we are"; } run-bash-function This version is not: run-bash-function run-bash-function() { echo "Here we are"; } Cheers, Greg --0000000000003af8ac0626902f24 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
What problem are you trying to solve? If you tell us that,= we can guide you to some better solutions.

There are numerous= issues here, but the most important are:

1) Calling a s= hell via \! invokes an entirely new process: there is no link to the parent= or grandparent process

2) The run-bash-function m= ust be declared before being called, so that bash code was never going to w= ork anyway. In other words, this is valid:

run-bas= h-function() { echo "Here we are"; }

run-bash-function

This version is not:

ru= n-bash-function

run-bash-function() { echo &= quot;Here we are"; }


Chee= rs,
Greg

--0000000000003af8ac0626902f24--