/usr/sbin/lightdm-session: 34: [: Linux: unexpected operator

Bug #962270 reported by Barry Warsaw
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
lightdm (Ubuntu)
Invalid
Low
Unassigned

Bug Description

I guess my .bash_profile isn't being executed with bash? I get this in the first few lines of my .xsession-errors file:

/usr/sbin/lightdm-session: 34: [: Linux: unexpected operator
/usr/sbin/lightdm-session: 53: /home/barry/.bash_profile: source: not found

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report, could you attach your /usr/sbin/lightdm-session to the bug?

Changed in lightdm (Ubuntu):
status: New → Incomplete
importance: Undecided → Low
Revision history for this message
Barry Warsaw (barry) wrote :
Changed in lightdm (Ubuntu):
status: Incomplete → New
Revision history for this message
Sebastien Bacher (seb128) wrote :

weird, that doesn't really make sense to me, l34 is "XKB_IN_USE=yes", how can that hit the error in the summary?

Revision history for this message
Barry Warsaw (barry) wrote : Re: [Bug 962270] Re: /usr/sbin/lightdm-session: 34: [: Linux: unexpected operator

On Mar 29, 2012, at 07:02 PM, Sebastien Bacher wrote:

>weird, that doesn't really make sense to me, l34 is "XKB_IN_USE=yes",
>how can that hit the error in the summary?

Exactly! :)

I can't explain it either.

-Barry

Revision history for this message
hamish (hamish-b) wrote :

your line numbers are off by +3 (going from "53: /home/barry/.bash_profile: source: not found"), but still no "a == b" bashisms or unquoted enviro variables that I can see...

which version is this?

Hamish

Revision history for this message
Barry Warsaw (barry) wrote :

On May 31, 2012, at 03:25 AM, hamish wrote:

>your line numbers are off by +3 (going from "53:
>/home/barry/.bash_profile: source: not found"), but still no "a == b"
>bashisms or unquoted enviro variables that I can see...
>
>which version is this?

I'm still seeing this in quantal. From the top of my .xsession-errors file:

/usr/sbin/lightdm-session: 34: [: Linux: unexpected operator
/usr/sbin/lightdm-session: 53: /home/barry/.bash_profile: source: not found

It's certainly weird because ~/.bash_profile does exist.

I can't see that any harm is occurring in quantal though.

Revision history for this message
Barry Warsaw (barry) wrote :

My guess is that the Line 34 is related to my .bash_profile, which has this on line 34:

if [ "`uname -s`" == "Darwin" ]
then
    # On MacOS X, the $PATH is set in .MacOSX/environment.plist
    export PATH=$PATH:/opt/local/bin
    # Path to emacsclient.
    export EDITOR=/Applications/Emacs.app/Contents/MacOS/bin/emacsclient
fi

Line 53 has this:

    source $HOME/.bashrc

This does seem to have negative impact on my session, as my xmodmap keyboard settings aren't getting set in Quantal now.

Revision history for this message
Philippe Poilbarbe (cardolan) wrote :

/usr/sbin/lightdm-session is a script executed with /bin/sh (see shebang line "#!/bin/sh").
It sources $HOME/.profile (and some others), not $HOME/.bash_profile.

So things specific to bash and not in sh are not recognized, for example:
if [[ "$x" == "yes " || "$y" != "no" ]]
then
fi

must be written:
if [ "$x" == "yes" -o "$y" != "no" ]
then
fi

Another way to overide this is to modify /usr/sbin/lightdm-session: replace "/bin/sh" by "/bin/bash"
Everything wich is good for sh is good for bash (but not the opposite).

Revision history for this message
Barry Warsaw (barry) wrote :

On Jul 03, 2012, at 11:10 AM, Philippe Poilbarbe wrote:

>/usr/sbin/lightdm-session is a script executed with /bin/sh (see shebang line
>"#!/bin/sh"). It sources $HOME/.profile (and some others), not
>$HOME/.bash_profile.

This does make it rather impossible to set up the environment both for the
login session and for e.g. ssh or console logins without duplicating a lot of
code. What's the rationale for using /bin/sh in lightdm by default?

>So things specific to bash and not in sh are not recognized, for example:
>if [[ "$x" == "yes " || "$y" != "no" ]]
>then
>fi
>
>must be written:
>if [ "$x" == "yes" -o "$y" != "no" ]
>then
>fi

I don't have [[ in my .profile, but there are other syntactic subtleties that
make it difficult to share init files between lightdm and bash.

>Another way to overide this is to modify /usr/sbin/lightdm-session: replace
>"/bin/sh" by "/bin/bash" Everything wich is good for sh is good for bash (but
>not the opposite).

Having to manually hack this file on every installed machine is definitely
suboptimal, not only because of the work involved, but also because an update
of lightdm will just clobber those changes. Isn't there some less brittle way
we could arrange for lightdm to use bash?

Revision history for this message
ZachG (zgold550) wrote :

I'm also running into this issue on two of my machines. Both are Asus X53U laptops running almost 100% stock versions of Ubuntu 12.04. I've installed nothing but chrome and gnome-panel on the machines. This manifests as users not being able to login using lightdm to the machines.

I see an identical error in .xsession-errors as reported above:

Changing the interpreter from sh to bash in lightdm-session allows users to login to the machines.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lightdm (Ubuntu):
status: New → Confirmed
Revision history for this message
hamish (hamish-b) wrote :

'if [ a == b ]' is a bashism. you need to do 'if [ a = b ]' instead if the shebang is #!/bin/sh.

Hamish

Revision history for this message
Sebastien Bacher (seb128) wrote :

@hamish: thanks for debugging this!

Closing the bug, Barry it seems it's just a bash specific syntax in your user config and that turning it to a proper posix syntax should fix the issue

Changed in lightdm (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
MetaChrome (imagenesis) wrote :

This needs to be reopened.

1. It's possible that the .profile should be executed with the user's shell.
2. It would appear that for some user's, .profile happens to be executed with bash (or the user's shell) and in other cases it is executed with /bin/sh.
3. Please specify at what point in the execution of lightdm is it determined which shell to execute lightdm-session and/or source profile.

Revision history for this message
MetaChrome (imagenesis) wrote :

Nevermind, I don't know why I was under the impression that some users execute X session with anything other than /bin/sh.

Revision history for this message
MetaChrome (imagenesis) wrote :

Please specify why lightdm-session's shell script is not called interactively? The default declaration in bashrc is to return if bashrc is called non-interactively.

Revision history for this message
Hang Fire (hangfirew8) wrote :

I suddenly got this bug after an update; my primary user login does NOT work. I can log in on a text alternate console; or as Guest.

What is interesting is I have NO user customizations to any ~/.bash* files; so the critique above does NOT apply to me.

.xsession looks like this:
/usr/bin/lightdm-session: 1: /etc/profile: id: not found
/usr/bin/lightdm-session: 12: [: Illegal number:
/usr/bin/lightdm-session: 1: /usr/sbin/lighdm-session: ls: not found
/usr/bin/lightdm-session: 104: exec: ghome-session: not found

As sudo I edited lightdm-session and put in some full paths; it only results in more downstream errors.

Since this is a box-stock 13.10 install and blew out after an update, I recommend re-opening this bug.

Revision history for this message
Luis Pinho (lj-pinho) wrote :

A possible temporary workaround for this, is to create a .profile file, if it not already exists and add the following line:

bash ~/.bash_profile

This is what I have to do to all my 150 LDAP users, now it works.

Revision history for this message
Steven Shaw (steshaw) wrote :

@lj-pinho, Unfortunately that solution will not work if you have Bash-specific shell syntax in your .bash_profile (and why wouldn't you?).

I'm currently having this same issue because of using `[[ ]]` instead of `[ ]` and source instead of `.`. I _knew_ there was a good reason I'd previously changed all my `[[ ]]` to `[ ]` in my `.profile` file. However, there's also a good reason to not have a `.bash_profile` and only have a `.profile` but I'm forgetting what that is at the moment. Can anyone enlighten me? I do use these dotfiles across Linux, Mac, FreeBSD and (not recently) Solaris, UX, AIX, Cygwin, MinGW. Mainly my dotfiles need to be portable across Linux and Mac.

Cheers!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.