From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Nils <nils(at)nilsand(dot)re> |
Cc: | pgsql-www(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Improve portability of pgweb/load_initial_data.sh |
Date: | 2021-11-08 09:03:50 |
Message-ID: | CABUevEz5X8qSCNEveNOU19Gy3FcOXdRgpP=Z33KUbDw=DNs_cA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-www |
Hi!
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?
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.
//Magnus
On Sun, Nov 7, 2021 at 5:49 PM Nils <nils(at)nilsand(dot)re> 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/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Magnus Hagander | 2021-11-08 09:32:54 | Re: [PATCH] Fix inaccuracies in documentation |
Previous Message | Nils | 2021-11-07 17:13:56 | [PATCH] Fix inaccuracies in documentation |