That indeed would run .profile only once, but now introduces the problem
that it dumps the entire environment, and all bash functions in set, and
has to read and evaluate it back:

$ set|wc -l
14698

Reading and evaluating 15.000 lines of shell  is not a triviality.

Also, can we make sure that more complicated variable or alias
definitions actually correctly survive this subshell/set/sed/eval round?
I have some stuff like

  alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo
terminal || echo error)" "$(history|tail -n1|sed -e
'\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

(now a standard value for new user accounts in Ubuntu) and also stuff
like

if [ "$TERM" = xterm -a -z "$SSH_TTY" ]; then
    export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    export PS1="${debian_chroot:+\[\e[31m[$debian_chroot]\] }\[\e[31m\]\$? 
\[\e[30m\]\$(parse_git_branch)\[\e[32m\]\u@\h:\[\e[34m\]\w\n$\[\e[22m\]\[\e[30m\]
 "
fi

Also, functions that rely on variables like $$, or having a terminal as
stdout/stderr would break.

As I already said, I don't think that there is any easy and efficient
solution for this -- this is very much like t,he halting problem, shell
is a Turing complete programming language after all. Also, it would
again paper over the actual bug that the user introduced into his
.profile -- we should tell him about it, instead of trying to interpret
something half-working into broken scripts, which then also would only
apply to particular environments like gdm. The next time the user would
log into a VT, log into the box with ssh, use screen, or run a cron/at
job it would break all over again.

I think the only really sensible solution here is to produce an error
message.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/678421

Title:
  Error in ~/.profile halts the X startup

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/678421/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to