SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
One of the pulseaudio helper scripts, specifically "/etc/bash_completion.d/pacat" breaks xdm. When /etc/X11/xdm/Xsession is executed it sources it and fails:
Code:
/etc/bash_completion.d/pacat: line 6: syntax error near unexpected token `<'
/etc/bash_completion.d/pacat: line 6: ` done < <(pactl list cards short 2> /dev/null)'
It makes xdm return to login screen immediately after typing an username and password and pressing Enter. Really, annoying as hell. It took me a few hours to hunt it down. A quick search shows that the issue is know on this forum: http://www.linuxquestions.org/questi...in-4175534973/, https://www.linuxquestions.org/quest...688/page5.html. I just wanted to check if pulseaudio would make it possible to modify my wireless speakers volume on software level because ALSA cannot do that. Not only didn't, but also made me waste several hours of my life. What a sad day.
EDIT: I don't think it should be fixed by a package maintainer, it's a PulseAudio problem. There can be a few similar bug reports found on google
I just had a look at this (I'm interested since I am the SBo pulseaudio package maintainer) but I can't replicate the problem. I have exactly the line that is quoted in /etc/bash_completion.d/pacat (actually one of several symlinks to pulseaudio script) but no syntax problem is reported. I tried xdm in 2 ways; firstly by promoting it in rc.4, secondly by running xdm from runlevel 3 command line.
The "fix" of removing the relevant completion script is pretty unsatisfying (although I have previously suggested it myself here). As mentioned in the other report,
If you have bash-completion installed.
than pulseaudio generate errors on some systems.
.
i.e. some systems - which suggests to me that the pulseaudio bash completion script is not itself necessarily faulty, just triggering some other fault. Sorry I can't suggest what that other fault might be; and hard for me chase up myself since I can't replicate the fault.
Seems to me that being 'interactive' in nature, the bash completion stuff really belongs in .bashrc and not .profile, and/or at the very least should be wrapped in a
Code:
case $- in
*i*) # Interactive Shell invocation.
# Insert bash completion stuff here #
;;
esac
Having said that, the stock 'Xsession' file is pretty horrid, and I've never liked how it repeatedly runs through /etc/profile. I rewrote mine.
Oh, and, 'startx' isn't particularly great either.
Can I ask you something - what's the shebang line in your /etc/X11/xdm/Xsession?
My /etc/X11/xdm/Xsession has #!/bin/sh
Quote:
EDIT: If you also have #!/bin/sh, are you sure that you have bash_completion.sh in /etc/profile.d/?
Somewhat embarrassingly, no. When I made one I could see your problem with xdm immediately closing down and returning to login screen - however I didn't see your pulseaudio error messages anywhere.
However kdm worked OK and to me, that leads to the real question - why it would cause failure with xdm but not kdm? I compared the /etc/X11/xdm/Xsession with /etc/kde/kdm/Xsession and found they both sourced /etc/profile (which in turn sources scripts in /etc/profile.d, one of which now sources /etc/bash_completion/* files). The kde version sets posix compatibility mode before sourcing /etc/profile. When I changed xdm/Xsession to do the same thing, I was able to successfully log in with xdm while keeping bash completion.
If you want to try it, insert
Code:
set +o posix
immediately before line 62 (if [ -r $profile ]; then). Now your xdm might work again.
I just had a thought - rather than adding the posix mode in the xdm/Xsession file, it would be less intrusive if it were placed in the script that sources all the /etc/bash_completion/* files. For me, that is /etc/profile.d/bash_completion.sh, although I'll think some more about that location after GazL's comment. I add "set -o posix" in /etc/profile.d/bash_completion.sh before sourcing the bash_completion files and xdm still works.
That should work with other login managers too - would you care to try that with your GDM stormtracknole?
I just had a thought - rather than adding the posix mode in the xdm/Xsession file, it would be less intrusive if it were placed in the script that sources all the /etc/bash_completion/* files. For me, that is /etc/profile.d/bash_completion.sh, although I'll think some more about that location after GazL's comment. I add "set -o posix" in /etc/profile.d/bash_completion.sh before sourcing the bash_completion files and xdm still works.
That should work with other login managers too - would you care to try that with your GDM stormtracknole?
chris
I can give that a try this weekend. Thanks for the tip!
I just had a thought - rather than adding the posix mode in the xdm/Xsession file, it would be less intrusive if it were placed in the script that sources all the /etc/bash_completion/* files.
As long as that script itself isn't sourced, otherwise /etc/profile sources the contents of profile.d/*, and Xsession sources /etc/profile, so any set -o you issued in a script in profile.d will get sourced and apply to the shell that's actually running the entire thing. Basically, you'd still be adding posix mode to Xsession, you'd just be hiding the fact by having it nested 2 levels of sourcing down.
As I said above, bash_completion is really only helpful for interactive shells, so I'd be inclined to wrap it in the case/esac statement which would prevent it from running when Xsession sources it.
BTW, What I did with mine (though once again I've completely deviated from what ships with Slackware), is I have my Xsession source /etc/xprofile, not /etc/profile. /etc/xprofile then sources the contents of /etc/xprofile.d, which just contains symlinks to any /etc/profile.d members that are appropriate for the X11 environment. i.e. I set it up with: mkdir /etc/xprofile.d && cd /etc/xprofile.d && ln -s ../profile.d/*.sh .
I then delete any symlinks that aren't appropriate for the X environment.
I'm happy to share my Xsession and xprofile files if people want them, but I'm going a little off-topic here, so I'll save that for another thread/day. (PM me if you're interested).
However kdm worked OK and to me, that leads to the real question - why it would cause failure with xdm but not kdm? I compared the /etc/X11/xdm/Xsession with /etc/kde/kdm/Xsession and found they both sourced /etc/profile (which in turn sources scripts in /etc/profile.d, one of which now sources /etc/bash_completion/* files). The kde version sets posix compatibility mode before sourcing /etc/profile. When I changed xdm/Xsession to do the same thing, I was able to successfully log in with xdm while keeping bash completion.
Indeed, POSIX mode is the culprit here but I thought it works the opposite way. This is why a script that sources pulseaudio completion file that has /bin/bash shebang does not crash. In man bash it says:
Code:
When invoked as sh, bash enters posix mode after the startup files are read.
As on Slackware /bin/sh is a symlink to bash, here it actually matters how the script is called. And now we might know what pulseaudio developers meant by "some systems" - those where their bash completion script is executed in POSIX mode.
I agree that completions should not be sourced for a non-interactive shell at all.
Last edited by average_user; 09-11-2015 at 10:42 AM.
As long as that script itself isn't sourced, otherwise /etc/profile sources the contents of profile.d/*, and Xsession sources /etc/profile, so any set -o you issued in a script in profile.d will get sourced and apply to the shell that's actually running the entire thing. Basically, you'd still be adding posix mode to Xsession, you'd just be hiding the fact by having it nested 2 levels of sourcing down.
I was wondering about that - making everything posix through sourcing a chain of scripts. However that leads to the question of whether its a bad thing. I mean, the kdm/Xsession which I've been using (though I use XFCE desktop) already changes to posix mode anyway, regardless of any bash completion issues. Perhaps the xdm's Xsession (and any others) should be doing the same thing?
I think you're wrong. kdm/Xsession does not enable POSIX mode, it disables it:
Code:
# Note that the respective logout scripts are not sourced.
case $SHELL in
*/bash)
[ -z "$BASH" ] && exec $SHELL $0 "$@"
set +o posix
From `help set':
Code:
Using + rather than - causes these flags to be turned off.
Compare 2 scripts with a different shebang line I posted in an earlier post and an excerpt from Bash manpage. If shebang line is /bin/sh sourcing pulseaudio completion script fails because Bash works in POSIX mode. See also here https://stackoverflow.com/questions/...s-substitution
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.