FS#36959 - [xorg-xinit/gcc?] Empty lines before #!/bin/sh in startx

Attached to Project: Arch Linux
Opened by Leonid Isaev (lisaev) - Monday, 16 September 2013, 22:43 GMT
Last edited by Andreas Radke (AndyRTR) - Sunday, 27 October 2013, 15:14 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Andreas Radke (AndyRTR)
Laurent Carlier (lordheavy)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Since xinit 1.3.3 (but the problem is also present in git), the startx shell script contains lots of empty lines before the shebang. This confuses bash making it start additional login shell ('-bash' in ps(1)).

Apparently, this is not an upstream issue [1] and it was suggested that cpp is to blame...

THanks,
Leonid.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=69439
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Sunday, 27 October 2013, 15:14 GMT
Reason for closing:  Fixed
Additional comments about closing:  1.3.3-2
Comment by Allan McRae (Allan) - Wednesday, 18 September 2013, 05:35 GMT
The output from the C preprocessor is perfectly fine - especially if it was preprocessing a C file... Using a C preprocessor as a fancy sed on a shell script falls in the category of not my problem.
Comment by Baeyens (berbae) - Wednesday, 18 September 2013, 15:04 GMT
As a workaround I use now in my .bash_profile :

...
if [[ $XDG_VTNR == 1 ]]; then
[[ -e $HOME/.startx ]] || (/usr/bin/uniq /usr/bin/startx |\
sed -n '/^#!/,$p' > $HOME/.startx && chmod 755 $HOME/.startx)

[[ -x $HOME/.startx ]] && $HOME/.startx &> $HOME/xsession.log
fi

And the additional login shell disappears.
Comment by Leonid Isaev (lisaev) - Wednesday, 18 September 2013, 18:57 GMT
Of course you also could have written "eval bash /usr/bin/startx"...
Comment by Adrian Todd (solarshado) - Monday, 30 September 2013, 04:40 GMT
This might should be a separate bug, but I noticed the same thing in /etc/X11/xinit/xinitrc.pacnew: a bunch of blank lines before the shebang.
Comment by Leonid Isaev (lisaev) - Tuesday, 01 October 2013, 16:46 GMT
Yes, xinitrc suffers from the same problem.

I agree with Allan in that cpp is not supposed to be a sed replacement. But I also think this bug unlikely to be fixed upstream which most likely used cpp for portability reasons. Moreover, wayland is on the horizon, so I don't know how relevant this xorg package will be.

Hence, I suggest to fix this in package(), e.g.

sed -i '/^\s*$/d' $pkgdir/usr/bin/startx
sed -i '/^\s*$/d' $pkgdir/etc/X11/xinit/xinitrc
Comment by Andrea D'Amore (anddam) - Sunday, 06 October 2013, 09:23 GMT
I agree with just fixing the two scripts. As it is now the package is just broken for the users and the fix is really straightforward.

Loading...