I've clearly become incapable of solving what seemed to me a simple rtfm issue. This line works fine on the command line (both zsh and bash):-
[[ -f ${HOME}/.xsessionrc.local ]] && . ${HOME}/.xsessionrc.local
When I put it in my .xsessionrc (shebanged with bash) it doesn't.
Am I misunderstanding that double square brackets should work? As I say, they do on the bash command line.
Both these lines work (when uncommented):-
It's not so much that I need that first to work as clearly I can use one of the other forms, but why doesn't it work "in script" but does when used directly from the command line? Some nuance about how XSession sources .xsessionrc?
# F=${HOME}/.xsessionrc.local;[ -f $F ] && . $F
# [ -f ~/.xsessionrc.local ] && . ${HOME}/.xsessionrc.local
Thanks for your patience. I'm blind to it now. I've spent hours on this ;)
bash
andzsh
and others can use[[ ... ]]
./bin/sh
can not. The shell that is executing your.xsessionrc
file is not your login script but whatever shell the graphical login session manager (GDM?) is picking, most likely/bin/sh
since it's available on any Unix system. The/bin/sh
shell may not, as I said, understand the double square bracket test syntax. – Kusalananda Jan 02 '21 at 09:35#!
line would not matter if the file is sourced, or executed with an explicit interpreter. – Kusalananda Jan 02 '21 at 09:35