Discussion:
FVWM: $PATH in Test x
Dominique Michel
2012-05-01 18:53:50 UTC
Permalink
A very common way to write $HOME in a path is with ~

I have the following functions:

DestroyFunc Music-Start
AddToFunc Music-Start
+ I Exec exec $0

DestroyMenu /Music/Start
AddToMenu /Music/Start
+ '$[gt.Start MPlayer]' Music-Start "mplayer -slave -idle -input
file=/home/$[USERDIR]/.mplayer/pipe"
Test (x xdradio) + '$[gt.Start XDRadio]' Music-Start "xdradio"

The xdradio file is into ~/bin and I start fvwm with startx.

With "PATH="~/bin:$PATH" into ~/.bash_profile, I get only the first
menu line on the screen.
With "PATH="/home/dom/bin:$PATH" into ~/.bash_profile, I get the 2
menu lines on the screen.

It look like the "Test (x xdradio) ..." work only in the first case.
Is it a bug in fvwm or somewhere else, or some obscure and wanted stuff
I am not aware of?

Ciao,
Dominique
Jaimos F Skriletz
2012-05-01 19:46:13 UTC
Permalink
Post by Dominique Michel
A very common way to write $HOME in a path is with ~
With "PATH="~/bin:$PATH" into ~/.bash_profile, I get only the first
menu line on the screen.
With "PATH="/home/dom/bin:$PATH" into ~/.bash_profile, I get the 2
menu lines on the screen.
It look like the "Test (x xdradio) ..." work only in the first case.
Is it a bug in fvwm or somewhere else, or some obscure and wanted stuff
I am not aware of?
It is an issue with the shell, and how it expands special characters.
When the shell encounters an Env Variable or a special character like ~,
*, !, etc it exapnds it based on the rules of the character.

So when you have PATH="~/bin/:$PATH" because of the way the shell works
it will expand $PATH correctly but it will not mess with the character
"~" because it is inside quotes. What you should do it type this in a shell

echo $PATH

and you will see that your PATH still contains the ~ and it wasn't
expanded to your home directally like it should have been. What this
does is confuse things that use the PATH variable. Some may expand the ~
but my guess is most won't. It is preferable to do

PATH="$HOME/bin:$PATH" to ensure everything gets expanded correctly by
the shell.

Another issue is putting a * or a ? in there would also cause issues
because the shell is instructed to not expand things because of being
between quotes.

jaimos
Thomas Adam
2012-05-01 20:28:48 UTC
Permalink
Post by Dominique Michel
A very common way to write $HOME in a path is with ~
With "PATH="~/bin:$PATH" into ~/.bash_profile, I get only the first
menu line on the screen.
With "PATH="/home/dom/bin:$PATH" into ~/.bash_profile, I get the 2
menu lines on the screen.
It look like the "Test (x xdradio) ..." work only in the first case.
Is it a bug in fvwm or somewhere else, or some obscure and wanted stuff
I am not aware of?
It is an issue with the shell, and how it expands special characters. When
the shell encounters an Env Variable or a special character like ~, *, !,
etc it exapnds it based on the rules of the character.
Not for the Test command, it isn't. This doesn't have anything to do
with the shell or the quoting problems you'd find there. And
actually, this is inherent in the environment FVWM is using for
itself, not in ~/.bash_profile, which unless sourced before FVWM
starts, might not have the same PATH set as interactive shells.

-- Thomas Adam
Dominique Michel
2012-05-02 22:04:16 UTC
Permalink
Le Tue, 1 May 2012 21:28:48 +0100,
On 1 May 2012 20:46, Jaimos F Skriletz
Post by Jaimos F Skriletz
Post by Dominique Michel
A very common way to write $HOME in a path is with ~
With "PATH="~/bin:$PATH" into ~/.bash_profile, I get only the first
menu line on the screen.
With "PATH="/home/dom/bin:$PATH" into ~/.bash_profile, I get the 2
menu lines on the screen.
It look like the "Test (x xdradio) ..." work only in the first
case. Is it a bug in fvwm or somewhere else, or some obscure and
wanted stuff I am not aware of?
It is an issue with the shell, and how it expands special
characters. When the shell encounters an Env Variable or a special
character like ~, *, !, etc it exapnds it based on the rules of the
character.
Not for the Test command, it isn't. This doesn't have anything to do
with the shell or the quoting problems you'd find there. And
actually, this is inherent in the environment FVWM is using for
itself, not in ~/.bash_profile, which unless sourced before FVWM
starts, might not have the same PATH set as interactive shells.
On gentoo, ~/.bash_profile is sourced one time at login and $PATH is
the same than for the interactive shells (if it is not defined
differently into ~/.bashrc for the laters). After the login, I start
fvwm with startx. So, it is sourced before fvwm starts, and as Jaimos
pointed out, the ~ is not expanded by the shell.

Anyway, I will stop to use ~ in my config and use $HOME instead.

Thanks,
Dominique

Loading...