[indiana-discuss] Code review request
Roland Mainz
roland.mainz at nrubsig.org
Thu Jan 31 17:13:10 PST 2008
David.Comay at Sun.COM wrote:
>
> http://cr.opensolaris.org/~comay/webrev-p1-1/
>
> This addresses for the next Live CD preview the following reported
> issues
>
> 97 Prompt (PS1) should be customized
> 205 manpath should be set to include all installed man directories
> 339 /usr/X11/bin should be in default $PATH
[snip]
+#
+# Define default prompt to <username>@<hostname>:<path><"($|#) ">
+# Print '#' for user "root" and '$' for normal users
+#
+PS1='${LOGNAME}@$(hostname):$(
+ [[ "$LOGNAME" = "root" ]] && printf "\w# " || printf "\w\$ ")'
+export PS1
Erm....
1. putting the PS1 setting into /etc/profile is IMO not a good idea
since this is 1) shell-specific, 2) belongs into the setup for
_interactive_ shell sessions (/etc/profile is for login shells (and not
all interactive shells are login shells and nothing says that login
shells must be interactive)) and 3) will affect other people's script
(PS1 should never be exported into the environment). AFAIK this stuff
belongs into /etc/bash.bashrc or ~/.bashrc since it assumes bash's
non-standard expansion for "\w" ; the matching ksh93 file is
/etc/ksh.kshrc
2. The "\w" must be escaped by an extra '\', otherwise you're ending-up
with undefined behaviour (e.g. outside what the POSIX standard defines)
of /usr/bin/printf (and the upcoming rework of /usr/bin/printf may then
present you with an unexpected result or even an error message) (To be
honestly I did the same mistake, that's why the new /usr/bin/printf will
be less forgiving when someone tries to input reserved or malformed
format patterns)
3. AFAIK the "\\w" can be replaced with "\$PWD" (or "\${PWD}") - making
this more portable (e.g. it should work with bash and ksh93)
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)
More information about the indiana-discuss
mailing list