#1001724 /usr/bin/firefox is difficult to wrap

Package:
firefox-esr
Source:
firefox-esr
Description:
Mozilla Firefox web browser - Extended Support Release (ESR)
Submitter:
Joey Hess
Date:
2021-12-14 21:18:06 UTC
Severity:
normal
#1001724#5
Date:
2021-12-14 20:18:36 UTC
From:
To:
I have a ~/bin/firefox wrapper script ahead of the usual firefox in PATH.

#!/bin/sh
MOZ_USE_XINPUT2=1 /usr/bin/firefox "$@"

This has a very surprising behavior, because /usr/bin/firefox contains:

FIREFOX="$(command -v firefox)"
[ -x "$FIREFOX.real" ] && exec "$FIREFOX.real" "$@"

So FIREFOX gets set to ~/bin/firefox and there is no ~/bin/firefox.real
to run. So instead it falls through and runs firefox-esr which I also happen
to have installed. Since firefox-esr doesn't use my usual firefox
config, my wrapper script effectively breaks the configuration.

The workaround was to change my wrapper script to this:

#!/bin/sh
MOZ_USE_XINPUT2=1 PATH=/usr/bin:$PATH exec firefox "$@"

Although notice that this can turn into an infinite loop if firefox
is somehow not in /usr/bin anymore. Also it prevents firefox from running
any other wrapper scripts I might have in ~/bin when starting a program
such as a PDF viewer. So this is a suboptimal workaround.

I don't know if there is a reason you are not using $0 or not simply
hardcoding the path to firefox.real, either seems like a way to avoid this.

#1001724#10
Date:
2021-12-14 21:14:59 UTC
From:
To:
reassign 1001724 firefox-esr
thanks

Using $0 causes #818159. I guess hardcoding /usr/bin/firefox would work.

Mike