[GRASS-dev] [GRASS GIS] #132: Extend GRASS-command history (at least to 1000) by default

#132: Extend GRASS-command history (at least to 1000) by default
-------------------------+--------------------------------------------------
Reporter: nikos | Owner: grass-dev@lists.osgeo.org
     Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Keywords: |
-------------------------+--------------------------------------------------
Why not extend the command-history by default?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by neteler):

I fully agree, it is too small (but was recently enlarged to 3000 for
bash), esp. for csh:

{{{
grep -in hist lib/init/init.sh
888: echo "set history = 500 savehist = 500 noclobber ignoreeof" >>
"$cshrc"
889: echo "set histfile = $HOME/.history" >> "$cshrc"
927: # save command history in mapset dir and remember more
928: export HISTFILE="$LOCATION/.bash_history"
929: if [ -z "$HISTSIZE" ] && [ -z "$HISTFILESIZE" ] ; then
930: export HISTSIZE=3000
}}}

History size should at least be identical for all shells.

Markus

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by hamish):

ok, updated to 3000 for csh and cygwin cases in r31030.

Before closing this wish, I notice that for Ubuntu (/bin/sh -> SHELL=dash)
it may miss out on all that nice stuff. Could an Ubuntu user with a fresh
checkout test?

  # from the GRASS> prompt
  echo $HISTSIZE

?
Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

GRASS GIS wrote:

#132: Extend GRASS-command history (at least to 1000) by default
-------------------------+--------------------------------------------------
Reporter: nikos | Owner: grass-dev@lists.osgeo.org
     Type: enhancement | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Keywords: |
-------------------------+--------------------------------------------------
Why not extend the command-history by default?

Are you talking about the shell's command history or a map's history?

For the latter, one problem is that the History structure uses
fixed-sized fields:

  #define MAXEDLINES 50
  #define RECORD_LEN 80
  
  ...
  
  struct History
  {
      char mapid[RECORD_LEN];
      char title[RECORD_LEN];
      char mapset[RECORD_LEN];
      char creator[RECORD_LEN];
      char maptype[RECORD_LEN];
      char datsrc_1[RECORD_LEN];
      char datsrc_2[RECORD_LEN];
      char keywrd[RECORD_LEN];
      int edlinecnt;
      char edhist[MAXEDLINES][RECORD_LEN];
  };

Increasing MAXLINES to 1000 could be a significant waste of memory for
modules which have a lot of maps open.

The I/O code only writes as many characters per line and as many lines
as are actually used, so disk space isn't a factor:

      fprintf (fd, "%s\n", hist->mapid) ;
      fprintf (fd, "%s\n", hist->title) ;
      fprintf (fd, "%s\n", hist->mapset) ;
      fprintf (fd, "%s\n", hist->creator) ;
      fprintf (fd, "%s\n", hist->maptype) ;
      fprintf (fd, "%s\n", hist->datsrc_1) ;
      fprintf (fd, "%s\n", hist->datsrc_2) ;
      fprintf (fd, "%s\n", hist->keywrd) ;
  
      for(i=0; i < hist->edlinecnt; i++)
        fprintf (fd, "%s\n", hist->edhist[i]) ;

It probably wouldn't be particularly hard to replace all of the arrays
with pointers, i.e.:

  struct History
  {
      char *mapid;
      char *title;
      char *mapset;
      char *creator;
      char *maptype;
      char *datsrc_1;
      char *datsrc_2;
      char *keywrd;
      int edlinecnt;
      char **edhist;
  };

The main issue is that any modules which fill in the history fields
themselves (rather than simply calling e.g. G_short_history()) would
need to use e.g.:

  hist.datasrc_1 = G_store(src);

instead of:

  strcpy(hist.datasrc_1, src);

Tracking down all such cases might take a while.

--
Glynn Clements <glynn@gclements.plus.com>

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by hamish):

(2nd call)

Before closing this wish, I notice that for Ubuntu (/bin/sh -> SHELL=dash)
it may miss out on all that nice stuff. Could an Ubuntu user with a fresh
checkout test?

     # from the GRASS> prompt echo $HISTSIZE

what does it say?

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by epatton):

Using fresh svn update from today, I get a $HISTFILE size of 5000...but
HISTSIZE gets exported to 3000 in Init.sh:

{{{
888: echo "set history = 3000 savehist = 3000 noclobber ignoreeof" >>
"$cshrc"
889: echo "set histfile = $HOME/.history" >> "$cshrc"
927: # save command history in mapset dir and remember more
928: export HISTFILE="$LOCATION/.bash_history"
929: if [ -z "$HISTSIZE" ] && [ -z "$HISTFILESIZE" ] ; then
930: export HISTSIZE=3000
}}}

But I can't remember if this difference is due to some change I made
elsewhere on my system.

~ Eric.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

GRASS GIS wrote:

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by epatton):

Using fresh svn update from today, I get a $HISTFILE size of 5000...but
HISTSIZE gets exported to 3000 in Init.sh:

{{{
888: echo "set history = 3000 savehist = 3000 noclobber ignoreeof" >> "$cshrc"
889: echo "set histfile = $HOME/.history" >> "$cshrc"
927: # save command history in mapset dir and remember more
928: export HISTFILE="$LOCATION/.bash_history"
929: if [ -z "$HISTSIZE" ] && [ -z "$HISTFILESIZE" ] ; then
930: export HISTSIZE=3000
}}}

But I can't remember if this difference is due to some change I made
elsewhere on my system.

The code doesn't touch HISTSIZE if either HISTSIZE or HISTFILESIZE are
already set.

It's quite possible that one of those is being set in one of the
(many) shell startup scripts, i.e. /etc/profile, ~/.bash_profile,
~/.bash_login, ~/.profile, ~/.bashrc, or any script which is sourced
from one of those.

Many systems have a whole directory (e.g. /etc/profile.d or
/etc/env.d) of scripts which are sourced from /etc/profile, in order
to allow individual packages to customise the environment.

In addition, programs which are involved in initialising X sessions
(e.g. xdm/gdm/kdm, Gnome/KDE, the window manager, etc) may set
environment variables which will then be inherited by any shells.

Finally, any "login" program (e.g. xdm/gdm/kdm) normally uses PAM,
which may set environment variables via the pam_env module.

All in all, determining how an environment variable gets set can
sometimes require exhaustive knowledge of your process' ancestors and
their behaviour.

--
Glynn Clements <glynn@gclements.plus.com>

#132: Extend GRASS-command history (at least to 1000) by default
--------------------------+-------------------------------------------------
  Reporter: nikos | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: unspecified
Resolution: fixed | Keywords:
--------------------------+-------------------------------------------------
Changes (by hamish):

  * status: new => closed
  * resolution: => fixed

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/132#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>