]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
_emergency_shell: Show current working directory correctly in shell.
authorWANG Chao <chaowang@redhat.com>
Fri, 26 Apr 2013 07:16:19 +0000 (15:16 +0800)
committerHarald Hoyer <harald@redhat.com>
Tue, 30 Apr 2013 10:13:56 +0000 (12:13 +0200)
When dropped to emergency shell, for example, use rd.break=pre-pivot,
the PS1 won't correctly show current directory we're in:

pre-pivot:/# cd /sysroot/
pre-pivot:/#
(still shows "/")

Let's take a look at PS1 variable:

(I'm adding prefix/suffix 'x' to make it clear):
pre-pivot:/# echo x${PS1}x
xpre-pivot:/# x
(PS1 isn't dynamic)

Regarding the current dracut code, it should be:

pre-pivot:/# cd /sysroot/etc
pre-pivot:/sysroot/etc#

With this patch:

pre-pivot:/# echo x${PS1}x
xpre-pivot:${PWD}# x
(Now PS1 is dynamic, it will show the directory correctly)

I tested for both normal boot and kdump boot.

Signed-off-by: WANG Chao <chaowang@redhat.com>
modules.d/99base/dracut-lib.sh

index 9bd25f46dacbb887862ad78dd30b8be724207d4b..5cb0add5740ca89560640270c40c2b2ac5706083 100755 (executable)
@@ -926,7 +926,7 @@ _emergency_shell()
     local _name="$1"
     if [ -n "$DRACUT_SYSTEMD" ]; then
         > /.console_lock
-        echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
+        echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile
         systemctl start dracut-emergency.service
         rm -f /etc/profile
         rm -f /.console_lock