Преглед изворни кода

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.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65347 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras пре 10 година
родитељ
комит
1d491d1d2c
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      lib/init/grass.py

+ 3 - 3
lib/init/grass.py

@@ -1427,9 +1427,9 @@ def bash_startup(location, location_name, grass_env_file):
     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 @@ def default_startup(location, location_name):
         # 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