On Sun, Aug 30, 2009 at 05:46:02PM -0700, [email protected] wrote:
> [ pkg-discuss moved to the Bcc as this clearly isn't pkg(5) related ]
> ># Define default prompt to <username>@<hostname>:<path><"($|#) ">
> ># and print '#' for user "root" and '$' for normal users.
> >#
> >PS1='${logna...@$(/usr/bin/hostname):$(
> >   [[ "${LOGNAME}" == "root" ]] && printf "%s" "${PWD/${HOME}/~}# " ||
> >   printf "%s" "${PWD/${HOME}/~}\$ ")'
> >
> >Is there any reason why it cannot be just
> >
> >PS1="\...@\h:\w\$ "
> 
> It's for compatibility with other shells such as ksh93

Interestingly, ${PWD/${HOME}/~} doesn't quite work as expected in ksh93:
the '~' gets expanded back to $HOME, so that ${PWD/${HOME}/~} is a
no-op.  Putting a backslash in front of the tilde helps in ksh93, but
bash doesn't know to drop the escape:

bash% echo "${PWD/${HOME}/\~}# "
\~/tmp# 
bash% 

ksh93% echo "${PWD/${HOME}/\~}# "
~/tmp# 
ksh93% 

This works on both:

% TILDE=$(echo \~)
% echo "${PWD/${HOME}/$TILDE}# "
~/tmp# 
% 

Bash does expand ~ in TILDE=$(echo ~) and it does respect the backslash
in TILDE=$(echo \~), but not in echo ${PWD/${HOME}/...}.  A bug in bash?
Obnoxious, certainly.

Nico
-- 
_______________________________________________
indiana-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/indiana-discuss

Reply via email to