Browse Source

startup: Start shell from start_shell() (#1953)

Huidae Cho 3 years ago
parent
commit
7a2cafaae6
1 changed files with 13 additions and 11 deletions
  1. 13 11
      lib/init/grass.py

+ 13 - 11
lib/init/grass.py

@@ -1879,6 +1879,15 @@ def show_info(shellname, grass_gui, default_gui):
     message("")
 
 
+def start_shell():
+    if WINDOWS:
+        # "$ETC/run" doesn't work at all???
+        process = subprocess.Popen([os.getenv("SHELL")])
+    else:
+        process = Popen([gpath("etc", "run"), os.getenv("SHELL")])
+    return process
+
+
 def csh_startup(location, grass_env_file):
     userhome = os.getenv("HOME")  # save original home
     home = location
@@ -1922,7 +1931,7 @@ def csh_startup(location, grass_env_file):
     f.close()
     writefile(tcshrc, readfile(cshrc))
 
-    process = Popen([gpath("etc", "run"), os.getenv("SHELL")])
+    process = start_shell()
     os.environ["HOME"] = userhome
     return process
 
@@ -2075,22 +2084,15 @@ PROMPT_COMMAND=grass_prompt\n""".format(
     f.write('trap "exit" TERM\n')
     f.close()
 
-    process = Popen([gpath("etc", "run"), os.getenv("SHELL")])
+    process = start_shell()
     os.environ["HOME"] = userhome
     return process
 
 
 def default_startup(location, location_name):
     """Start shell making no assumptions about what is supported in PS1"""
-    if WINDOWS:
-        os.environ["PS1"] = "GRASS > "
-        # "$ETC/run" doesn't work at all???
-        process = subprocess.Popen([os.getenv("SHELL")])
-    else:
-        os.environ["PS1"] = "GRASS > "
-        process = Popen([gpath("etc", "run"), os.getenv("SHELL")])
-
-    return process
+    os.environ["PS1"] = "GRASS > "
+    return start_shell()
 
 
 def done_message():