[Bug 678421] Re: Error in ~/.profile halts the X startup
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 Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
For the sed/eval round we can always escape the special characters beforehand, there should be some function for that. But I agree with your conclusion. Warning or message is a good enough solution, even though I would like to see some hand-holding. I agree it just isn't worth the effort and the only nice way (I can think) of doing this is to extend dash with such functionality. ** Summary changed: - Error in ~/.profile halts the X startup + Error message for a faulty ~/.profile script -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error message for a faulty ~/.profile script To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/678421/+subscriptions -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
Hmm... Now this is above my head (again). ;-) One thing that it does not seem to handle is setting of aliases. ** Changed in: gdm (Ubuntu) Status: Incomplete = Confirmed -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
The idea is simple: ### VARS=$( # this allows to capture subshell stdout to a variable . $HOME/script.sh 1/dev/null # this prevents script printing something to stdout set # this prints all variables to stdout alias | sed 's/.*/alias \0/' # this prints aliases to stdout and prefixes them with alias ) || ERRCODE=$? if [ $ERRCODE==0 ] then eval $VARS # if everything is ok, we reevaluate the variables and aliases in this shell fi ### Now the VARS=$(command) || ERRCODE=$?, || prevents the command from exiting the script if the next command exits with code 0. We could also use VARS=$(command) || true, but then $? would contain the result of command true, since ERRCODE=$? also exits with code 0 we can prevent the shell from exiting and remember the correct error code. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
I'll ask Martin P. to take a look. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
Right forgot about the variables. After poking around in dash source I found that $HOME/.profile has been hardcoded. So the change needs be made in the shell to make .profile safe. Also I found a way to keep the variables from subshell ### test.sh ### ERRCODE=0 TEST= VARS=$(set -e; . $HOME/script.sh 1/dev/null; set) || ERRCODE=$? if [ $ERRCODE==0 ] then eval $VARS fi echo ERRCODE = $ERRCODE echoTEST = $TEST ### script.sh ### TEST=something function AddPath { echo err } ## This also has one nice thing that when the script fails the environment stays unchanged. Also there may be some variables that shouldn't be taken from the subshell, but I have no idea which. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
Sorry, I forgot about this due to other duties (work and school). This is not an active issue for me, but would be a nice touch to Ubuntu. This still happens in Oneiric (tested in daily). There are some differences, it just drops you into the default login screen without any explanation. Which is quite bad because then you will be puzzled what just happened/went wrong. Also I did some research how to keep the main script running when sub-script has some syntax errors: # set -e ERRCODE=0 (. $HOME/.profile) || ERRCODE=$? echo $ERRCODE # ERRCODE will be 0 if everything was ok 127 if there was a syntax error 0: there was some other problem with the script That way we can get the correct error code without terminating the main script and do graceful handling of the error. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
Nice try, Egon, but I think your solution has the same drawbacks as the idea I mentioned in comment #2. The parentheses would make the ~/.profile commands be run in a subprocess, so if no error, you would need to source ~/.profile in the main process as well, or else settings of e.g. environment variables via ~/.profile would not work. In other words, normally ~/.profile would be sourced twice. ** Changed in: gdm (Ubuntu) Status: Expired = Incomplete -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
We're closing this bug since it is has been some time with no response from the original reporter. However, if the issue still exists please feel free to reopen with the requested information. Also, if you could, please test against the latest development version of Ubuntu, since this confirms the bug is one we may be able to pass upstream for help. ** Changed in: gdm (Ubuntu) Status: Incomplete = Expired -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in 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 -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
I don't actually think that silently ignoring ~/.profile if it has errors is actually a good and expected behaviour. After all, the user just changed his ~/.profile and now restarted the session, perhaps to test the effect. The best thing to me would be a dialog box that actually showed the error that the shell command encountered, and then exit the session. That might actually be possible with zenity or similar. We should at least ensure that the error appears in ~/.xsession-errors, then we at least have some point of feedback. So from my POV the current bug title is wontfix. I'm fine with renaming it to better error message for broken ~/.profile, if you prefer that? -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
Sure, silently just ignoring is just as bad. I just think that, it's a mistake that shouldn't prevent you to login and start up everything. The ~/.profile script can also easily be changed by non-experienced users (ones who may not know terminal that well). If that user doesn't get the session running then he'll be forced to use terminal. The ideal case I think would be: everything starts up and an relevant error message is displayed. I'm ok with scripts in /etc/.. preventing xsession to start as that requires sudo permissions (as sudo implies that caution must be taken). Essentially my POV is that if modifying a script doesn't require sudo permissions it should be relatively safe, meaning you should be still able to fix it from GUI interface. Of course practically it's impossible to do so, but it's a target to move towards. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
I agree on the goal you describe, Egon, which is why I made an attempt to fix it. However, while the run ~/.profile twice proposal was rejected due to its disadvantages, it's the only way I was able to figure out that would prevent syntax errors from stopping the startup. I leave it to you to decide if you want to go for Martin's idea and convert this bug to rather be about error messages. In the case of a syntax error, the error message currently is logged in .xsession-errors (as the last entry). Have no idea, though, how to make it trigger e.g. a zenity dialog. Unassigning myself from this bug in the hope that someone with more experience from exception handling in dash will give it a shot. ** Branch unlinked: lp:~gunnarhj/gdm/profile ** Branch unlinked: lp:~ubuntu-desktop/gdm/ubuntu ** Changed in: gdm (Ubuntu) Status: In Progress = Confirmed ** Changed in: gdm (Ubuntu) Assignee: Gunnar Hjalmarsson (gunnarhj) = (unassigned) ** Changed in: gdm (Ubuntu) Status: Confirmed = Incomplete -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
As regards efficiency, ~/.profile typically contains something like this: if [ -n $BASH_VERSION ]; then # [ code that won't be run in bourne shell ] fi if [ -d $HOME/bin ] ; then PATH=$HOME/bin:$PATH fi export LANGUAGE=en export LC_MESSAGES=en_US.UTF-8 export LANG=sv_SE.UTF-8 -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
** Branch unlinked: lp:~gunnarhj/gdm/profile -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
** Branch linked: lp:~gunnarhj/gdm/profile -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
I want to correct myself: When discussing this with more experienced developers, my attention was called to the fact that I had missed the distinction between syntax errors and other errors. While a syntax error kills the process, other errors, e.g. not found, don't. Hence you can disregard my talk about the -e option. A possible solution did come up. Replacing this /etc/gdm/Xsession line: test -f $HOME/.profile . $HOME/.profile with test -f $HOME/.profile ( . $HOME/.profile ) . $HOME/.profile would protect against a ~/.profile syntax error causing the process to be killed. For two reasons it's not considered appropriate, at least not as soon before the 11.04 release as we are now: 1. Regression risk due to the ~/.profile commands being run twice (even if they would be run in a subprocess the first time). 2. Efficiency loss. For the case the conclusion will change after the 11.04 release, a merge proposal with the above solution is available. -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
** Branch linked: lp:~gunnarhj/gdm/profile -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
I had to set the -e option (errexit) in Xsession to make a ~/.profile error interrupt the startup. AFAICT that option is not set in the original Xsession script in GDM for Ubuntu. Anyway, maybe there are still cases where a ~/.profile error may lead to the behavior you describe. The linked branch contains an idea for a fix that would handle ~/.profile and ~/.xprofile in a safer way. If the solution is considered sensible, I suppose it should be forwarded upstream. Will await feedback before doing so. ** Branch linked: lp:~ubuntu-desktop/gdm/ubuntu ** Changed in: gdm (Ubuntu) Status: New = In Progress ** Changed in: gdm (Ubuntu) Assignee: (unassigned) = Gunnar Hjalmarsson (gunnarhj) -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in Ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs
[Bug 678421] Re: Error in ~/.profile halts the X startup
** Changed in: gdm (Ubuntu) Importance: Undecided = Low -- You received this bug notification because you are a member of Ubuntu Desktop Bugs, which is subscribed to gdm in ubuntu. https://bugs.launchpad.net/bugs/678421 Title: Error in ~/.profile halts the X startup -- desktop-bugs mailing list desktop-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/desktop-bugs