[Libguestfs] [PATCH] appliance: init: properly set PS1 and TERM for virt-rescue (RHBZ#812970).

Pino Toscano ptoscano at redhat.com
Tue Jun 10 13:18:38 UTC 2014


Setting environment variables such as PS1 for bash before starting it
might not be effective when the startup scripts provided by the
distribution unconditionally change it.
Hence, set PS1 and TERM in a ~/.bashrc, which will be source'd last and
thus be able to set them the way we want.
---
 appliance/init | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/appliance/init b/appliance/init
index 8d13f2c..b407bf9 100755
--- a/appliance/init
+++ b/appliance/init
@@ -142,9 +142,10 @@ else
   # Remove LD_PRELOAD=libSegFault set above.
   unset LD_PRELOAD
 
-  eval $(grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline)
-  PS1='><rescue> '
-  export TERM PS1
+  :> $HOME/.bashrc
+  grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline >> $HOME/.bashrc
+  echo "PS1='><rescue> '" >> $HOME/.bashrc
+  echo "export TERM PS1" >> $HOME/.bashrc
 
   echo
   echo "------------------------------------------------------------"
-- 
1.9.3




More information about the Libguestfs mailing list