[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#122817: More food for thought



On Sat, Jun 26, 2004 at 05:23:11PM +0200, Javier Fernández-Sanguino Peña wrote:
> I had this suggestions lying in my INBOX and I believe are worth pointing
> out. Even if programs do not rely or depend on an specific environment
> being set it is, for sure, a way to enhace the behaviour of many programs.
> 
> Also notice that, regarding the complaints made by Bill, that scripts in
> profile.d can be forced to be fully POSIX compliant (like we do for
> maintainer scripts). Please do not shrug off the idea just because the 
> implementations made by other distributions are bash-specific, we can make 
> ours non-bash-specific if we wanted to.

Debian shells are not required to be POSIX compliant, only /bin/sh.
In practice, I expect you will have a hard time to write shell scripts
that are valid for both tcsh and bash.

I would like to point out that the correct way in Debian to set
environnement variable for all users is to use /etc/environnement.

That said, I have no objections to /etc/profile.d provide it affects
only bash and packages do not use it for user-wide settings, but only
for bash tweaking. Unfortunately the examples below let me wonder
whether that is not be too open to abuse.

Cheers,
Bill.

> ==> /etc/profile.d/bash.sh <==
> shopt -s checkwinsize

This is already in /etc/bash.bashrc in both woody and sid.
 
> ==> /etc/profile.d/colorls.sh <==
> # color-ls initialization
> COLORS=/etc/DIR_COLORS

I don't think this is needed on Debian.
 
> if echo $SHELL |grep bash 2>&1 >/dev/null; then # aliases are bash only
>   if ! egrep -qi "^COLOR.*none" $COLORS &>/dev/null; then
>         alias ll='ls -l '
>         alias l.='ls -d .[a-zA-Z]* '
>         alias ls='ls '
>   else
>         alias ll='ls -l'
>         alias l.='ls -d .[a-zA-Z]*'
>   fi
> fi

bash-only, could go in /etc/profile

> ==> /etc/profile.d/gnome-ssh-askpass.sh <==
> SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
> export SSH_ASKPASS

This is an environnement variable.

> ==> /etc/profile.d/IBMjava.sh <==
> echo $PATH | grep -q :/opt/IBMJava2-13/bin: ||\
>         export PATH=$PATH:/opt/IBMJava2-13/bin:/opt/IBMJava2-13/jre/bin

IBMjava is not even in non-free.

> ==> /etc/profile.d/lang.sh <==
> # /etc/profile.d/lang.sh - set i18n stuff
> 
> sourced=0
> for langfile in /etc/sysconfig/i18n $HOME/.i18n ; do
>     [ -f $langfile ] && . $langfile && sourced=1
> done

Debian do not use .i18n.

> if [ -n "$GDM_LANG" ]; then
>     sourced=1
>     LANG="$GDM_LANG"
> fi
> 
> if [ "$sourced" = 1 ]; then
>     [ -n "$LANG" ] && export LANG || unset LANG
>     [ -n "$LC_ADDRESS" ] && export LC_ADDRESS || unset LC_ADDRESS
>     [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
>     [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
>     [ -n "$LC_IDENTIFICATION" ] && export LC_IDENTIFICATION || unset 
> LC_IDENTIFICATION
>     [ -n "$LC_MEASUREMENT" ] && export LC_MEASUREMENT || unset LC_MEASUREMENT
>     [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES

This seems terribly clumsy.

> ==> /etc/profile.d/less.sh <==
> # less initialization script (sh)
> [ -x /usr/bin/lesspipe.sh ] && export LESSOPEN="|/usr/bin/lesspipe.sh %s"
> 
> if [ x`echo $LANG | cut -b 1-2` = x"ja" ]; then
>         export JLESSCHARSET=japanese;
> elif [ x`echo $LANG | cut -b 1-2` = x"ko" ]; then
>         export JLESSCHARSET=ko;
> fi

Should not be bash specific and LESSOPEN is a security concern.
If JLESSCHARSET is important, less should probably be changed to
handle that itself.

> ==> /etc/profile.d/mc.sh <==
> mc ()
> {
>         mkdir -p $HOME/.mc/tmp 2> /dev/null
>         chmod 700 $HOME/.mc/tmp
>         MC=$HOME/.mc/tmp/mc-$$
>         /usr/bin/mc -P "$@" > "$MC"
>         cd "`cat $MC`"
>         /bin/rm -f "$MC"
>         unset MC;
> }

cd `/usr/bin/mc -P "$@"` 
won't work ?

> ==> /etc/profile.d/qt.sh <==
> # Qt initialization script (sh)
> if [ -z "$QTDIR" ] ; then
>         QTDIR="/usr/lib/qt3-gcc2.96"
> fi
> export QTDIR

Not required on Debian, fortunately.

> ==> /etc/profile.d/vim.sh <==
> if echo $SHELL |grep bash 2>&1 >/dev/null; then # aliases are bash only
>         alias vi=vim
> fi

We have the dpkg-alternative system which do a better job.

> ==> /etc/profile.d/which-2.sh <==
> # Initialization script for bash and sh
> 
> # export AFS, if you are in AFS environment
> alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot 
> --show-tilde'

Debian 'which' does not support any options outside -a.

> Some of those are standard Red Hat, some are mine.

> It's a convenience for administrators and developers alike. I wrote bash.sh 
> because I want that to be the way _my_ site operates. I fret that IBM doesn't 

shopt -s checkwinsize is set by default on Debian.

> have one for Java to its environment variables correctly. A site might one 
> for Java so as to set CLASSPATH to point to site-wide Java classes.
> 
> Feel free to cite this to push your argument.

That rather shows the amount of cruft in Red Hat profile.d...

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 



Reply to: