[GRASS-SVN] r65347 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 1 07:42:58 PDT 2015


Author: wenzeslaus
Date: 2015-06-01 07:42:58 -0700 (Mon, 01 Jun 2015)
New Revision: 65347

Modified:
   grass/trunk/lib/init/grass.py
Log:
init: escape backslash in prompt string

This avoids anomalous-backslash-in-string warning (W1401) in Pylint. It is just a warning because the unknown escape sequence is ignored and thus the backslash is preserved for bash. The other solution would be to use raw strings but this complicates usage of newline character. BTW, backslash lowercase w means 'current absolute path' for bash.


Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2015-06-01 04:04:56 UTC (rev 65346)
+++ grass/trunk/lib/init/grass.py	2015-06-01 14:42:58 UTC (rev 65347)
@@ -1427,9 +1427,9 @@
     f = open(bashrc, 'w')
     f.write("test -r ~/.alias && . ~/.alias\n")
     if os.getenv('ISISROOT'):
-        f.write("PS1='ISIS-GRASS %s (%s):\w > '\n" % (grass_version, location_name))
+        f.write("PS1='ISIS-GRASS %s (%s):\\w > '\n" % (grass_version, location_name))
     else:
-        f.write("PS1='GRASS %s (%s):\w > '\n" % (grass_version, location_name))
+        f.write("PS1='GRASS %s (%s):\\w > '\n" % (grass_version, location_name))
 
     f.write("""grass_prompt() {
 	LOCATION="`g.gisenv get=GISDBASE,LOCATION_NAME,MAPSET separator='/'`"
@@ -1470,7 +1470,7 @@
         # TODO: why this is missing in the other startups?
         cleanup_dir(os.path.join(location, ".tmp"))  # remove GUI session files from .tmp
     else:
-        os.environ['PS1'] = "GRASS %s (%s):\w > " % (grass_version, location_name)
+        os.environ['PS1'] = "GRASS %s (%s):\\w > " % (grass_version, location_name)
         exit_val = call([gpath("etc", "run"), os.getenv('SHELL')])
 
     # TODO: this seems to be inconsistent, the other two are no fataling



More information about the grass-commit mailing list