Blame 0042-_emergency_shell-Show-current-working-directory-corr.patch

Harald Hoyer e2c90d
From b6f2e05819d9867b7ca69365091ff480556fcfe9 Mon Sep 17 00:00:00 2001
Harald Hoyer e2c90d
From: WANG Chao <chaowang@redhat.com>
Harald Hoyer e2c90d
Date: Fri, 26 Apr 2013 15:16:19 +0800
Harald Hoyer e2c90d
Subject: [PATCH] _emergency_shell: Show current working directory correctly in
Harald Hoyer e2c90d
 shell.
Harald Hoyer e2c90d
Harald Hoyer e2c90d
When dropped to emergency shell, for example, use rd.break=pre-pivot,
Harald Hoyer e2c90d
the PS1 won't correctly show current directory we're in:
Harald Hoyer e2c90d
Harald Hoyer e2c90d
pre-pivot:/# cd /sysroot/
Harald Hoyer e2c90d
pre-pivot:/#
Harald Hoyer e2c90d
(still shows "/")
Harald Hoyer e2c90d
Harald Hoyer e2c90d
Let's take a look at PS1 variable:
Harald Hoyer e2c90d
Harald Hoyer e2c90d
(I'm adding prefix/suffix 'x' to make it clear):
Harald Hoyer e2c90d
pre-pivot:/# echo x${PS1}x
Harald Hoyer e2c90d
xpre-pivot:/# x
Harald Hoyer e2c90d
(PS1 isn't dynamic)
Harald Hoyer e2c90d
Harald Hoyer e2c90d
Regarding the current dracut code, it should be:
Harald Hoyer e2c90d
Harald Hoyer e2c90d
pre-pivot:/# cd /sysroot/etc
Harald Hoyer e2c90d
pre-pivot:/sysroot/etc#
Harald Hoyer e2c90d
Harald Hoyer e2c90d
With this patch:
Harald Hoyer e2c90d
Harald Hoyer e2c90d
pre-pivot:/# echo x${PS1}x
Harald Hoyer e2c90d
xpre-pivot:${PWD}# x
Harald Hoyer e2c90d
(Now PS1 is dynamic, it will show the directory correctly)
Harald Hoyer e2c90d
Harald Hoyer e2c90d
I tested for both normal boot and kdump boot.
Harald Hoyer e2c90d
Harald Hoyer e2c90d
Signed-off-by: WANG Chao <chaowang@redhat.com>
Harald Hoyer e2c90d
---
Harald Hoyer e2c90d
 modules.d/99base/dracut-lib.sh | 2 +-
Harald Hoyer e2c90d
 1 file changed, 1 insertion(+), 1 deletion(-)
Harald Hoyer e2c90d
Harald Hoyer e2c90d
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer e2c90d
index 9bd25f4..5cb0add 100755
Harald Hoyer e2c90d
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer e2c90d
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer e2c90d
@@ -926,7 +926,7 @@ _emergency_shell()
Harald Hoyer e2c90d
     local _name="$1"
Harald Hoyer e2c90d
     if [ -n "$DRACUT_SYSTEMD" ]; then
Harald Hoyer e2c90d
         > /.console_lock
Harald Hoyer e2c90d
-        echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
Harald Hoyer e2c90d
+        echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile
Harald Hoyer e2c90d
         systemctl start dracut-emergency.service
Harald Hoyer e2c90d
         rm -f /etc/profile
Harald Hoyer e2c90d
         rm -f /.console_lock