* [PATCH] emergency_shell: Use '\W' in $PS1 variable to show current working directory.
@ 2013-03-12 5:01 WANG Chao
[not found] ` <1363064503-14783-1-git-send-email-chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: WANG Chao @ 2013-03-12 5:01 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
Signed-off-by: WANG Chao <chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/98systemd/dracut-emergency.sh | 2 +-
modules.d/99base/dracut-lib.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules.d/98systemd/dracut-emergency.sh b/modules.d/98systemd/dracut-emergency.sh
index a0a4b12..af8daf2 100755
--- a/modules.d/98systemd/dracut-emergency.sh
+++ b/modules.d/98systemd/dracut-emergency.sh
@@ -29,7 +29,7 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
echo
echo
[ -f /etc/profile ] && . /etc/profile
- [ -z "$PS1" ] && export PS1="$_name:\${PWD}# "
+ [ -z "$PS1" ] && export PS1="$_name:\W# "
exec sh -i -l
else
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index d2c803a..e96411e 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -906,7 +906,7 @@ _emergency_shell()
local _name="$1"
if [ -n "$DRACUT_SYSTEMD" ]; then
> /.console_lock
- echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
+ echo "PS1=\"$_name:\W# \"" >/etc/profile
systemctl start dracut-emergency.service
rm -f /etc/profile
rm -f /.console_lock
@@ -924,7 +924,7 @@ _emergency_shell()
echo
echo 'Dropping to debug shell.'
echo
- export PS1="$_name:\${PWD}# "
+ export PS1="$_name:\W# "
[ -e /.profile ] || >/.profile
_ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] emergency_shell: Use '\W' in $PS1 variable to show current working directory.
[not found] ` <1363064503-14783-1-git-send-email-chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2013-03-12 8:44 ` Harald Hoyer
[not found] ` <513EEB05.9050706-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Harald Hoyer @ 2013-03-12 8:44 UTC (permalink / raw)
To: WANG Chao; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
Am 12.03.2013 06:01, schrieb WANG Chao:
> Signed-off-by: WANG Chao <chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> modules.d/98systemd/dracut-emergency.sh | 2 +-
> modules.d/99base/dracut-lib.sh | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/modules.d/98systemd/dracut-emergency.sh b/modules.d/98systemd/dracut-emergency.sh
> index a0a4b12..af8daf2 100755
> --- a/modules.d/98systemd/dracut-emergency.sh
> +++ b/modules.d/98systemd/dracut-emergency.sh
> @@ -29,7 +29,7 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
> echo
> echo
> [ -f /etc/profile ] && . /etc/profile
> - [ -z "$PS1" ] && export PS1="$_name:\${PWD}# "
> + [ -z "$PS1" ] && export PS1="$_name:\W# "
> exec sh -i -l
> else
> warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
> index d2c803a..e96411e 100755
> --- a/modules.d/99base/dracut-lib.sh
> +++ b/modules.d/99base/dracut-lib.sh
> @@ -906,7 +906,7 @@ _emergency_shell()
> local _name="$1"
> if [ -n "$DRACUT_SYSTEMD" ]; then
> > /.console_lock
> - echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
> + echo "PS1=\"$_name:\W# \"" >/etc/profile
> systemctl start dracut-emergency.service
> rm -f /etc/profile
> rm -f /.console_lock
> @@ -924,7 +924,7 @@ _emergency_shell()
> echo
> echo 'Dropping to debug shell.'
> echo
> - export PS1="$_name:\${PWD}# "
> + export PS1="$_name:\W# "
> [ -e /.profile ] || >/.profile
>
> _ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
>
\W does not work with dash.
Maybe you want:
export PS1="[$_name:\${PWD##*/}]# "
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] emergency_shell: Use '\W' in $PS1 variable to show current working directory.
[not found] ` <513EEB05.9050706-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2013-03-12 10:01 ` WANG Chao
0 siblings, 0 replies; 3+ messages in thread
From: WANG Chao @ 2013-03-12 10:01 UTC (permalink / raw)
To: Harald Hoyer; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2384 bytes --]
On 03/12/2013 04:44 PM, Harald Hoyer wrote:
> Am 12.03.2013 06:01, schrieb WANG Chao:
>> Signed-off-by: WANG Chao <chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> modules.d/98systemd/dracut-emergency.sh | 2 +-
>> modules.d/99base/dracut-lib.sh | 4 ++--
>> 2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/modules.d/98systemd/dracut-emergency.sh b/modules.d/98systemd/dracut-emergency.sh
>> index a0a4b12..af8daf2 100755
>> --- a/modules.d/98systemd/dracut-emergency.sh
>> +++ b/modules.d/98systemd/dracut-emergency.sh
>> @@ -29,7 +29,7 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
>> echo
>> echo
>> [ -f /etc/profile ] && . /etc/profile
>> - [ -z "$PS1" ] && export PS1="$_name:\${PWD}# "
>> + [ -z "$PS1" ] && export PS1="$_name:\W# "
>> exec sh -i -l
>> else
>> warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
>> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
>> index d2c803a..e96411e 100755
>> --- a/modules.d/99base/dracut-lib.sh
>> +++ b/modules.d/99base/dracut-lib.sh
>> @@ -906,7 +906,7 @@ _emergency_shell()
>> local _name="$1"
>> if [ -n "$DRACUT_SYSTEMD" ]; then
>> > /.console_lock
>> - echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
>> + echo "PS1=\"$_name:\W# \"" >/etc/profile
>> systemctl start dracut-emergency.service
>> rm -f /etc/profile
>> rm -f /.console_lock
>> @@ -924,7 +924,7 @@ _emergency_shell()
>> echo
>> echo 'Dropping to debug shell.'
>> echo
>> - export PS1="$_name:\${PWD}# "
>> + export PS1="$_name:\W# "
>> [ -e /.profile ] || >/.profile
>>
>> _ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
>>
>
> \W does not work with dash.
I didn't take dash into consideration :(
> Maybe you want:
>
> export PS1="[$_name:\${PWD##*/}]# "
I didn't intend to break this long-working-directory convention. But
${PWD##*/} works for me.
The buggy line is:
echo "PS1=\"$_name:\${PWD}# \"" >/etc/profile
In this case, /etc/profile will be PS1="name:${PWD}# ", and ${PWD} will be
interpreted once at the time it being sourced.
It should be,
echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile.
Patch is attached. Thanks!
WANG Chao
[-- Attachment #2: 0001-_emergency_shell-don-t-let-PWD-being-interpreted-whe.patch --]
[-- Type: text/x-patch, Size: 970 bytes --]
From cfbd73c9f527a4845459cc995985ee87ff510156 Mon Sep 17 00:00:00 2001
From: WANG Chao <chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Tue, 12 Mar 2013 17:52:31 +0800
Subject: [PATCH] _emergency_shell: don't let $PWD being interpreted when
export $PS1
Signed-off-by: WANG Chao <chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/99base/dracut-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index d2c803a..954de2e 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -906,7 +906,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
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-12 10:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 5:01 [PATCH] emergency_shell: Use '\W' in $PS1 variable to show current working directory WANG Chao
[not found] ` <1363064503-14783-1-git-send-email-chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-03-12 8:44 ` Harald Hoyer
[not found] ` <513EEB05.9050706-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-03-12 10:01 ` WANG Chao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox