{"id":295,"date":"2011-02-09T16:12:51","date_gmt":"2011-02-09T13:12:51","guid":{"rendered":"http:\/\/www.held.org.il\/blog\/?p=295"},"modified":"2011-02-10T02:39:13","modified_gmt":"2011-02-09T23:39:13","slug":"solution-for-xsession-bash_completion-problem","status":"publish","type":"post","link":"http:\/\/www.held.org.il\/blog\/2011\/02\/solution-for-xsession-bash_completion-problem\/","title":{"rendered":"Solution for Xsession + bash_completion problem"},"content":{"rendered":"<p><strong>Update:<\/strong> just noticed that on a more advanced ~\/.profile, I see it sourcing ~\/.bashrc only if under bash (by using <em>if [ -n \"$BASH_VERSION\" ]; <\/em>).<\/p>\n<p>As Debian sid was just unfrozen due to Squeeze release, I recently get lots of package updates. I had the feeling that something is gonna break, even slightly, despite the relative high stability of Debian unstable.<\/p>\n<p>And indeed, after 100+ updates, I could no longer login to GNOME. I'm not sure which package update caused this (bash_completion was updated to 1.3, yet the problem isn't necessarily there) . gdm nicely referred me to ~\/.xsession-errors, which had something like:<br \/>\n<code>sh: \/etc\/bash_completion.d\/git: line 123: syntax error near unexpected token `&lt;'<br \/>\nsh: \/etc\/bash_completion.d\/git: line 123: `\tdone &lt; &lt;(git config -z --get-regexp '^(svn-remote\\..*\\.url|bash\\.showupstream)\u00ef\u00bb\u00bf\u00ef\u00bb\u00bf\u00ef\u00bb\u00bf\u00ef\u00bb\u00bf\u00ef\u00bb\u00bf 2&gt;\/dev\/null | tr '\\0\\n' '\\n ')'<br \/>\nsh: `_grub_mkpasswd-pbkdf2': not a valid identifier<br \/>\nsh: `_grub_script-check': not a valid identifier<\/code><\/p>\n<p>I couldn't find any related Debian bug report, nor hardly anything on the internet (just some\u00c2\u00a0<a href=\"https:\/\/bugs.archlinux.org\/task\/20264\">Arch Linux bugs<\/a> with no clear solution).<\/p>\n<p>Eventually I've found out that \/etc\/gdm\/Xsession uses \/bin\/sh (a crippled shell, even though it's a symlink to \/bin\/bash), which indeed fails with the same error when running 'source \/etc\/bash_completion'. This makes sense. <strong>bash_completion[*] should be bash-compatible, and may include bash-only non-standard-shell compliant syntax.<\/strong><\/p>\n<p>Wondering why Xsession gets to run ~\/.bash_completion indirectly, I've found that I had the following two abominations:<\/p>\n<ul>\n<li>'source ~\/.bashrc' command in ~\/.xsession<\/li>\n<li>'source ~\/.bashrc' command in ~\/.profile<\/li>\n<\/ul>\n<p>I'm not sure why I had these lines, but they shouldn't be there. Bash itself and only bash should source ~\/.bashrc (and it's done automatically when bash starts). It makes no sense for other shells to source it.<\/p>\n<p>So the solution was simply removing these lines from ~\/.profie and ~\/.xsession (actually got rid of ~\/.xsession completely). Still, I'm not sure which update triggered this problem.<\/p>\n<p>----<\/p>\n<p>* Actually the problem was in \/etc\/bash_completion\/git which is a part of the 'git' package and not the 'bash-completion' package. But all the same.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: just noticed that on a more advanced ~\/.profile, I see it sourcing ~\/.bashrc only if under bash (by using if [ -n &#8220;$BASH_VERSION&#8221; ]; ). As Debian sid was just unfrozen due to Squeeze release, I recently get lots of package updates. I had the feeling that something is gonna break, even slightly, despite [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[22,150,32,198,203,151],"_links":{"self":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/295"}],"collection":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/comments?post=295"}],"version-history":[{"count":0,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/media?parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/categories?post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.held.org.il\/blog\/wp-json\/wp\/v2\/tags?post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}