[GRASS5] Re: [GRASSLIST:6232] Re: gisdbase error

[moved here from grasslist]

On Fri, May 09, 2003 at 12:15:44PM +0100, Glynn Clements wrote:

Markus Neteler wrote:

> - graphical startup doesn't work -> bug in Init.sh?

> - cmd line startup with path to GISDBASE doesn't work -> bug in Init.sh?

Odd. At first I thought that it might be due to the use of
bash-specific features (Cygwin's /bin/sh is ash) but, apart from an
unrelated bug, it works with ash on Linux.

The unrelated bug is:

  trap "echo 'User break!' ; exit" 2 3 9 15

Signal 9 is SIGKILL, which can't be caught. bash seems to ignore this,
but it causes total failure under ash (attempting to run external
programs fails).

Ok, I'll clean that SIGKILL everywhere. But even deleting the
line didn't help.

Can you provide more details regarding the failures? You can get
debugging information by using "sh -x ...", i.e.

Yes, find attached (log_wingrass.txt.gz).

Row 91 of the log is showing a problem.

Markus

(attachments)

log_wingrass.txt.gz (1.28 KB)

Markus Neteler wrote:

> Can you provide more details regarding the failures? You can get
> debugging information by using "sh -x ...", i.e.

Yes, find attached (log_wingrass.txt.gz).

Row 91 of the log is showing a problem.

The $GISRC file is broken or absent. Non-interactive startup only
works once you have a valid $GISRC file, not for first-time use. This
is also true on Linux.

Non-interactive startup builds the $GISRC file using:

          sed -e "s|^GISDBASE:.*$|GISDBASE: $GISDBASE|; \
            s|^LOCATION_NAME:.*$|LOCATION_NAME: $LOCATION_NAME|; \
            s|^MAPSET:.*$|MAPSET: $MAPSET|" "$GISRC" > "$GISRC.$$"

This changes the existing $GISRC settings for GISDBASE, LOCATION_NAME
and MAPSET, but it won't add those settings if they aren't present.

The first-time use code does this:

    #for convenience, define pwd as GISDBASE:
    echo "GISDBASE: `pwd`" > "$GISRC"

The above sed command will then replace GISDBASE with the value from
the command-line, but LOCATION_NAME and MAPSET will remain undefined.
Hence the "LOCATION_NAME not set" error.

A simple fix is to change the first-time use code, e.g.:

    #for convenience, define pwd as GISDBASE:
    echo "GISDBASE: `pwd`" > "$GISRC"
    echo 'LOCATION_NAME: <UNKNOWN>' >> "$GISRC"
    echo 'MAPSET: <UNKNOWN>' >> "$GISRC"

A more involved fix would be to check for the presence of all of the
necessary settings, and add them if they aren't present (although this
should never occur after the first use), e.g.

  if ! grep LOCATION_NAME $GISRC >/dev/null 2>&1 ; then
    echo 'LOCATION_NAME: <UNKNOWN>' >> "$GISRC"
  fi
  if ! grep MAPSET $GISRC >/dev/null 2>&1 ; then
    echo 'MAPSET: <UNKNOWN>' >> "$GISRC"
  fi

  sed -e ...

--
Glynn Clements <glynn.clements@virgin.net>

On Fri, May 09, 2003 at 01:47:31PM +0100, Glynn Clements wrote:

Markus Neteler wrote:

> > Can you provide more details regarding the failures? You can get
> > debugging information by using "sh -x ...", i.e.
>
> Yes, find attached (log_wingrass.txt.gz).
>
> Row 91 of the log is showing a problem.

The $GISRC file is broken or absent. Non-interactive startup only
works once you have a valid $GISRC file, not for first-time use. This
is also true on Linux.

Ahh! Thanks for the quick investigation. So we miss(ed) a test here.

Non-interactive startup builds the $GISRC file using:

          sed -e "s|^GISDBASE:.*$|GISDBASE: $GISDBASE|; \
            s|^LOCATION_NAME:.*$|LOCATION_NAME: $LOCATION_NAME|; \
            s|^MAPSET:.*$|MAPSET: $MAPSET|" "$GISRC" > "$GISRC.$$"

This changes the existing $GISRC settings for GISDBASE, LOCATION_NAME
and MAPSET, but it won't add those settings if they aren't present.

The first-time use code does this:

    #for convenience, define pwd as GISDBASE:
    echo "GISDBASE: `pwd`" > "$GISRC"

The above sed command will then replace GISDBASE with the value from
the command-line, but LOCATION_NAME and MAPSET will remain undefined.
Hence the "LOCATION_NAME not set" error.

A simple fix is to change the first-time use code, e.g.:

    #for convenience, define pwd as GISDBASE:
    echo "GISDBASE: `pwd`" > "$GISRC"
    echo 'LOCATION_NAME: <UNKNOWN>' >> "$GISRC"
    echo 'MAPSET: <UNKNOWN>' >> "$GISRC"

A more involved fix would be to check for the presence of all of the
necessary settings, and add them if they aren't present (although this
should never occur after the first use), e.g.

  if ! grep LOCATION_NAME $GISRC >/dev/null 2>&1 ; then
    echo 'LOCATION_NAME: <UNKNOWN>' >> "$GISRC"
  fi
  if ! grep MAPSET $GISRC >/dev/null 2>&1 ; then
    echo 'MAPSET: <UNKNOWN>' >> "$GISRC"
  fi

  sed -e ...

Well, I don't know - please add whatever you think is better (compared to
efforts).

Thanks again!

Markus