*Synopsis*: ksh93 has strange default PS1

CR 6913851 changed on Jan 5 2010 by <User 1-PWPBN>

=== Field ============ === New Value ============= === Old Value =============

Public Comments        New Note                                               
Public Comments        New Note                                               
====================== =========================== ===========================

     
*Change Request ID*: 6913851

*Synopsis*: ksh93 has strange default PS1

  Product: solaris
  Category: shell
  Subcategory: korn93
  Type: Defect
  Subtype: 
  Status: 1-Dispatched
  Substatus: 
  Priority: 4-Low
  Introduced In Release: 
  Introduced In Build: 
  Responsible Engineer: 
  Keywords: 

=== *Description* ============================================================
$ env - ksh93
$ echo $PS1                                   
%s" COLUMNS "" printf "%...@%s:" "${LOGNAME}" "$(/usr/bin/hostname)" ellip="${ 
[[ "${LC_ALL}/${LANG}" == ~(Elr)(.*UTF-8/.*|/.*UTF-8) ]] && printf "\u[2026]
" || print "..." ; }" p="${PWD/~(El)${HOME}/\~}" (( ${#p} > 30 )) && print -r 
-n -- "${ellip}${p:${#p}-30:30}" || print -r -n -- "${p}" [[ "${LOGNAME}" == 
"root" ]] && print -n "# " || print -n "\$ " )

$ set | grep PS1                              
PS1=$'$(set +o xtrace +o errexit\n                printf "%*s\\r%s" COLUMNS 
""\n                printf "%...@%s:" "${LOGNAME}" 
"$(/usr/bin/hostname)"\n\t\tellip="${\n\t\t\t[[ "${LC_ALL}/${LANG}" == 
~(Elr)(.*UTF-8/.*|/.*UTF-8) ]] &&\n\t\t\t\tprintf "\\u[2026]\\n" || print "..." 
; }"\n\t\tp="${PWD/~(El)${HOME}/\\~}"\n\t\t(( ${#p} > 30 )) &&\n\t\t\tprint -r 
-n -- "${ellip}${p:${#p}-30:30}" ||\n\t\t\tprint -r -n -- "${p}"\n\t\t[[ 
"${LOGNAME}" == "root" ]] && print -n "# " || print -n "\\$ "\n\t\t)'

$ uname -a
SunOS xylabtecra 5.11 snv_130 i86pc i386 i86pc

With LOGNAME not set:

@xylabtecra:~/export/home/mj162486

*** (#1 of 1): 2010-01-04 09:29:04 GMT+00:00 <User 1-1SURPB>


=== *Public Comments* ========================================================
OpenSolaris ksh93 project lead Roland Mainz says:

The PS1 value reported in this bug is set in /etc/ksh.kshrc to provide
an user-friendly machine-wide default (see PSARC 2006/587). ksh93 itself
defaults to '$ ' as defined in the standard (using /etc/ksh.kshrc to set
PS1 allows us to both be standard-conformant and be user-friendly...  :-) 
).

Or short: This is not a bug.

*** (#1 of 4): 2010-01-05 03:37:41 GMT+00:00 <User 1-5Q-1267>

Well it is bug. There are at least two mistakes I see:

1) LOGNAME is not set in default enviroment, and the prompt looks as showed in 
description then

2) there is misleading ~ between : and <pwd> - the replacement of HOME does not 
work:

@xylabone:~/var$ pwd                                                            
/var

I will not study that overcomplicated setting to find the reason for 2), 1) is 
probably separate CR.

*** (#2 of 4): 2010-01-05 09:06:03 GMT+00:00 <User 1-1SURPB>

The reason for misleading ~ in

@xylabone:~/var$ pwd                                                            
/var

is probably that your $HOME is not set because you used env - ksh93 (correct me 
if I'm wrong).

But the PS1 is wrong anyway, for example if
HOME=/ab
PWD=/abc/de

it will show ~c/de as your path which is wrong.

To fix both issues (empty $HOME and HOME being part of PWD), replace this:
p="${PWD/~(El)${HOME}/\\~}"
with this:
case "$HOME" in ?*)p="${P/~(El)${HOME}(\/|$)/\~\1}";;*)p=$P;;esac

Oh yes, now someone tell me that perl is unreadable :)

*** (#3 of 4): 2010-01-05 10:07:40 GMT+00:00 <User 1-PWPBN>

Shorter version of my fix without using 'case'
p=$P;[[ -n $HOME ]]&&p="${P/~(El)${HOME}(\/|$)/\~\1}"

*** (#4 of 4): 2010-01-05 10:10:29 GMT+00:00 <User 1-PWPBN>


=== *Workaround* =============================================================

=== *Additional Details* =====================================================
        Targeted Release: 
        Commit To Fix In Build: 
        Fixed In Build: 
        Integrated In Build: 
        Verified In Build: 
  See Also: 6913823
  Duplicate of: 
  Hooks:
        Hook1: 
        Hook2: 
        Hook3: 
        Hook4: 
        Hook5: 
        Hook6: 
  Program Management: 
  Root Cause: 
  Fix Affects Documentation: No
  Fix Affects Localization: No

=== *History* ================================================================
        Date Submitted: 2010-01-04 09:29:03 GMT+00:00
        Submitted By: <User 1-1SURPB>

        Status Changed    Date Updated                  Updated By


=== *Service Request* ========================================================
        Impact: Limited
        Functionality: Primary
        Severity: 3
        Product Name: solaris
        Product Release: osol_2009.06
        Product Build: osol_2009.06
        Operating System: snv_130
        Hardware: x86
        Submitted Date: 2010-01-04 09:29:04 GMT+00:00


=== *Multiple Release (MR) Cluster* - 0 ======================================

Reply via email to