Project

General

Profile

Bug #882

Default $PS1 doesn't work properly

Added by River Tarnell over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-04-04
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

There are two problems with the default $PS1 on OI.

root@db:~# echo $PS1
${LOGNAME}@$(/usr/bin/hostname):$( [[ "${LOGNAME}" == "root" ]] && printf "%s" "${PWD/${HOME}/~}# " || printf "%s" "${PWD/${HOME}/~}\$ ")

1: Changing to a directory which contains $HOME as a substring gives wrong prompt:

root@db:/# echo $HOME
/root
root@db:/# mkdir /tmp/root
root@db:/# cd /tmp/root
root@db:/tmp~# 

2: After 'su', username doesn't change:

root@db:~# id
uid=0(root) gid=0(root)
root@db:~# su postgres
root@db:~# id
uid=90(postgres) gid=90(postgres)

History

#1

Updated by Roland Mainz over 8 years ago

Erm... the username should print who is logged-in. If you want to change this you have to use "su - username" and not "su username".

The issue with $HOME is just a missing left anchor in the regex pattern (my fault).

#2

Updated by Rich Lowe over 8 years ago

The use of $LOGNAME is contrary to what seems to be every other shell (well, those that actually have prompt expansion for username).

#3

Updated by Roland Mainz over 8 years ago

Rich Lowe wrote:

The use of $LOGNAME is contrary to what seems to be every other shell (well, those that actually have prompt expansion for username).

Erm... it's not "every other shell", it's the "every other (Linux) distribution" which use "\u" ("bash" (ksh93 can do it, too... there is a discipline function "plugin" for PS[1-4] which emulates bash4's "\<char>" system)) or pre-defined shell variables to get the user name for euid.

What I can easily do is to change this from $LOGNAME to euid (and make use of a static variable (typeset -S ...) to store the output of /usr/bin/hostname once to avoid that it is called each time...).

#4

Updated by Julian Wiesener about 8 years ago

  • Difficulty set to Medium
  • Tags set to needs-triage

1. seems to has been fixed

root@laphroaig:~# cd /tmp/root/
root@laphroaig:/tmp/root# p="${PWD/~(El)${HOME}/\~}"
root@laphroaig:/tmp/root# echo $p
/tmp/root

2. i would reject, it's not a bug.

if anyone want to improve /etc/ksh.kshrc, go ahead.

#5

Updated by Julian Wiesener about 8 years ago

  • Status changed from New to Closed

Also available in: Atom PDF