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 1mka3q-0008PW-GY for pgsql-www@arkaria.postgresql.org; Tue, 09 Nov 2021 22:57:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mka3o-0004Px-VP for pgsql-www@arkaria.postgresql.org; Tue, 09 Nov 2021 22:57:48 +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 1mka3o-0004Po-Ih for pgsql-www@lists.postgresql.org; Tue, 09 Nov 2021 22:57:48 +0000 Received: from 4.mo582.mail-out.ovh.net ([87.98.184.159]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mka3h-0006Xf-8s for pgsql-www@lists.postgresql.org; Tue, 09 Nov 2021 22:57:47 +0000 Received: from player735.ha.ovh.net (unknown [10.108.16.142]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id 87557234A3 for ; Tue, 9 Nov 2021 22:57:37 +0000 (UTC) Received: from nilsand.re (host86-151-117-224.range86-151.btcentralplus.com [86.151.117.224]) (Authenticated sender: nils@nilsand.re) by player735.ha.ovh.net (Postfix) with ESMTPSA id 1ACC723DFB18A; Tue, 9 Nov 2021 22:57:35 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-103G0058545ada6-eb7c-4df4-bd77-c55a6815f0c7, 5DE64B7FA63156736ED1FBFE24F6D474EF35397D) smtp.auth=nils@nilsand.re X-OVh-ClientIp: 86.151.117.224 Date: Tue, 9 Nov 2021 22:57:34 +0000 From: Nils Andre To: Magnus Hagander Cc: pgsql-www@lists.postgresql.org Subject: Re: [PATCH] Improve portability of pgweb/load_initial_data.sh Message-ID: <20211109225734.7evav44x7nf5c5jb@nixos> References: <20211107164951.wxcyp7iar2s4mjkn@nixos> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="v6jplmtrvfxobl7y" Content-Disposition: inline In-Reply-To: X-Ovh-Tracer-Id: 18221845570318925103 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvuddrudehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvffukfhfgggtuggjsehmtderredttddvnecuhfhrohhmpefpihhlshcutehnughrvgcuoehnihhlshesnhhilhhsrghnugdrrhgvqeenucggtffrrghtthgvrhhnpefhiedvtdevhfdvieegheetudekfeetffefleejieejkeffjeevvdehiedvgefgveenucffohhmrghinhepnhhigihoshdrohhrghdphhgrghgrnhguvghrrdhnvghtpdhrvgguphhilhhlqdhlihhnphhrohdrtghomhenucfkpheptddrtddrtddrtddpkeeirdduhedurdduudejrddvvdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrhejfeehrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepnhhilhhssehnihhlshgrnhgurdhrvgdprhgtphhtthhopehpghhsqhhlqdiffiifsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --v6jplmtrvfxobl7y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Mon, Nov 08, 2021 at 10:03:50AM +0100, Magnus Hagander wrote: > Yeah, I think the fact that it says bash is just a "knee-jerk default" and > not that it ever did either. So I have no problem changing that to sh. I'm > a bit curious though, as to in which scenario this actually causes a > problem? This causes problems on [NixOS][1] which only has `/bin/sh` and `/usr/bin/env` in the location one would "expect" them. > The second change I'm less sure about. There are many different things you > could change to break a script. This is one of them. You could change PATH, > or you could replace "find" or "xargs" with commands that don't work the > same way. CDPATH is not a variable that should, I believe, ever be exported > into non-interactive scripts in the first place. I didn't realise I was exporting CDPATH, which is ~~probably~~ a mistake (and would have prevented previous painful and long headaches). For what it's worth, I use a program I have written that makes use of CDPATH (and hence requires it to be exported (but I think I will reconsider the program's usage of CDPATH)). However I do understand this is an issue with my particular setup. Attached, is the patch amended without the CDPATH change. Thanks, Nils [1]: https://nixos.org/ > //Magnus > > On Sun, Nov 7, 2021 at 5:49 PM Nils wrote: > > > The shell script doesn't use bash extensions and bash may not be > > available on all systems at that location. > > > > If CDPATH is set, in certain cases, the call to cd can result in > > unwanted behaviour. > > --- > > pgweb/load_initial_data.sh | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/pgweb/load_initial_data.sh b/pgweb/load_initial_data.sh > > index fb16e70c..c419f298 100755 > > --- a/pgweb/load_initial_data.sh > > +++ b/pgweb/load_initial_data.sh > > @@ -1,4 +1,4 @@ > > -#!/bin/bash > > +#!/bin/sh > > > > # We keep this in a separate script because using initial_data.xxx in > > django will overwrite > > # critical data in the database when running a 'syncdb'. We'd like to > > keep the ability to > > @@ -8,7 +8,7 @@ echo WARNING: this may overwrite some data in the database > > with an initial set o > > echo 'Are you sure you want this (answer "yes" to overwrite)' > > read R > > > > -cd $(dirname $0) > > +CDPATH= cd $(dirname $0) > > > > if [ "$R" == "yes" ]; then > > find . -name data.json | xargs ../manage.py loaddata > > -- > > 2.31.1 > > > > > > > > > > -- > Magnus Hagander > Me: https://www.hagander.net/ > Work: https://www.redpill-linpro.com/ --v6jplmtrvfxobl7y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-load_initial_data.sh-bin-bash-bin-sh.patch"