Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#37540 - [dbus] 30-dbus script fails if errexit and nounset are set

Attached to Project: Arch Linux
Opened by Victor Engmark (l0b0) - Tuesday, 29 October 2013, 13:14 GMT
Last edited by Doug Newgard (Scimmia) - Wednesday, 18 March 2015, 00:07 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tom Gundersen (tomegun)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: I have `set -o errexit -o nounset` in my .xinitrc to avoid running the WM if any part of the .xinitrc behaves unexpectedly. The current version of 30-dbus <https://projects.archlinux.org/svntogit/packages.git/tree/trunk/30-dbus?h=packages/dbus> doesn't check whether the DBUS_SESSION_BUS_ADDRESS is *undefined*.

Additional info:
* dbus 1.6.16-1

Steps to reproduce:
1. Exit any X sessions.
1. $ unset DBUS_SESSION_BUS_ADDRESS
2. $ set -o errexit -o nounset
3. $ . /etc/X11/xinit/xinitrc.d/30-dbus

Result: The shell exits.

Simple fix attached.
This task depends upon

Closed by  Doug Newgard (Scimmia)
Wednesday, 18 March 2015, 00:07 GMT
Reason for closing:  Implemented
Additional comments about closing:  dbus 1.8.16-2
Comment by Victor Engmark (l0b0) - Tuesday, 29 October 2013, 13:17 GMT
Example .xinitrc which fails ("Failed to execute login command") because of this issue: <https://github.com/l0b0/tilde/blob/bf5328d6bcf3ab2b212990a5bc88e8a05bbe1848/.xinitrc>
Comment by Dave Reisner (falconindy) - Wednesday, 30 October 2013, 17:27 GMT
errexit and nounset are absolutely terrible things. 30-dbus explicitly *does* check if DBUS_SESSION_BUS_ADDRESS is defined, but it trips over your maligned shell options.
Comment by Victor Engmark (l0b0) - Wednesday, 30 October 2013, 23:25 GMT
I disagree. After some years doing various development I cannot bring myself to use shell scripts without brakes and a steering wheel.
Comment by Daniel Micay (thestinger) - Friday, 13 June 2014, 23:15 GMT
I don't really see a good way of checking if the variable is set without referencing it.
Comment by Victor Engmark (l0b0) - Sunday, 15 June 2014, 20:01 GMT
@Daniel: This is well established in POSIX: `${varname-replacement}` resolves to the value of the variable 'varname' if defined, and to 'replacement' (which can for example be a string literal or another expression such as a variable reference) otherwise. That code will not trigger `nounset`. Using an empty literal is a handy way to *explicitly* say that you don't care whether the variable is defined or not.
Comment by Daniel Micay (thestinger) - Sunday, 15 June 2014, 20:23 GMT
That would mean you need to make an assumption about what can and can not appear in the variable and the assumption may be invalidated by a future dbus update.
Comment by Victor Engmark (l0b0) - Sunday, 15 June 2014, 20:52 GMT
Using `${varname-}` means makes whether the variable is defined or not *explicitly* irrelevant to the execution of the script. Just using `$varname` makes the assumption that the variable will always be defined or that the sourcing shell has `nounset` disabled. The first assumption is wrong and the second is unnecessary, so why not do this?

Loading...