[GRASS-dev] [GRASS GIS] #4007: grass.py and bash: respect aliases in $HOME/.bashrc

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
-------------------------+---------------------------------
Reporter: neteler | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.8.2
Component: Default | Version: git-releasebranch78
Keywords: bash | CPU: Unspecified
Platform: Unspecified |
-------------------------+---------------------------------
At time aliases defined in $HOME/.bashrc are not transferred into the
GRASS GIS session (discussed in https://github.com/OSGeo/grass/pull/170
but not yet realised).

It would be way easier to work from command line if $HOME/.bashrc aliases
were carried over into the current session.

As per variables.html, `$HOME/.grass7/bashrc` has to be written by the
user which is unneeded extra work. Why this separate bashrc was invented
at all, is unknown to me...

Indeed, there has been some related discussion in Feb 2013:

https://lists.osgeo.org/pipermail/grass-dev/2013-February/061857.html (and
following)

Perhaps we can solve this in 2019/2020 :slight_smile:

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/4007&gt;
GRASS GIS <https://grass.osgeo.org>

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
--------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Default | Version: git-releasebranch78
Resolution: | Keywords: bash
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by hcho):

A workaround (current master) is to add

{{{
source ~/.bashrc
}}}

to $HOME/.grass7/bashrc.

I kind of understand why we have this separate bashrc (history for each
mapset), but I'm not sure why we have two different places to read this
file in grass.py: load_env (exports) and bash_startup (non-exports).
Hopefully, we can make it cleaner soon.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/4007#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
--------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Default | Version: git-releasebranch78
Resolution: | Keywords: bash
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

Replying to [comment:1 hcho]:
> A workaround (current master) is ...

To make this work in G78 as well, we would have to backport

https://github.com/OSGeo/grass/pull/170

...right? If yes, are there any any objections to do so?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/4007#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
--------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Default | Version: git-releasebranch78
Resolution: | Keywords: bash
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by hcho):

Replying to [comment:2 neteler]:
> Replying to [comment:1 hcho]:
> > A workaround (current master) is ...
>
> To make this work in G78 as well, we would have to backport
>
> https://github.com/OSGeo/grass/pull/170
>
> ...right? If yes, are there any any objections to do so?

You're right. No objection from me. Also, I guess this approach is better
than "forcing" `source ~/.bashrc`. Clean aliases vs. inheriting them.
Choice as long as we have a separate bashrc.

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

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
--------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.8.2
Component: Default | Version: git-releasebranch78
Resolution: | Keywords: bash
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

ok I have backported it (pls squash-merge in future - I had to cherry-pick
all commits individually).

Now: to be tested if it works in relbranch78

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

#4007: grass.py and bash: respect aliases in $HOME/.bashrc
--------------------------+---------------------------------
  Reporter: neteler | Owner: grass-dev@…
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.8.3
Component: Default | Version: git-releasebranch78
Resolution: | Keywords: bash
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by hcho):

Replying to [comment:4 neteler]:
> ok I have backported it (pls squash-merge in future - I had to cherry-
pick all commits individually).

I thought I used the Square and merge button in GitHub... Actually, this
seems to be the only way to merge from there, I guess? Not sure what
happened. Thanks for the backport!

>
> Now: to be tested if it works in relbranch78

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/4007#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>