Subject: FVWM: [HELP]PipeRead Strange Error Message

From: [email-masked]
Date: Sun, 16 May 2004 13:07:47 +0800

I try to build a dynamic menu to show
running fvwm modules.

DestroyMenu ModulePopup
AddToMenu ModulePopup
 + DynamicPopDownAction DestroyMenu ModuleList
 + MissingSubmenuFunction funcModuleList
 + "KillModule"    Popup   ModuleList

DestroyFunc funcModuleList
AddToFunc funcModuleList
 + I PipeRead `ps x|grep Fvwm|sed -e
"s/\\(.*\\)\\/\\(Fvwm[a-zA-Z]\\+\\).*/AddToMenu ModuleList \\2 KillModule
\\2/"|sort|uniq`

However, the PipeRead command stream is rendered as:
``28876 ?        R      0:00 sh -c ps x|grep Fvwm|sed -e
"s/\(.*\)\/\(Fvwm[a-zA-Z]\+\).*/AddToMenu ModuleList \2 KillModule
\2/"|sort|uniq"

And this causes an error message:
[FVWM][__execute_function]: <<ERROR>> No such command '28876'

Any idea how to fix this? Thank you!

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Parv <[email-masked]>
Date: Sun, 16 May 2004 22:17:21 -0400

in message <[email-masked]>,
wrote [email-masked] thusly...
> "s/\\(.*\\)\\/\\(Fvwm[a-zA-Z]\\+\\).*/AddToMenu ModuleList \\2 KillModule

If your sed allows, use a delimiter other than '/' so that you do
not have to escape it to reduce the clutter...

  echo 'damn/it' | sed -e 's!damn/!bloody !'

In other words, use a delimiter that does not occur in search
pattern or replacement to minimize number of things to focus on.

I have a feeling, but have not actually tried, that you may be
overescaping things in sed command.

  - Parv

--

---

From: Parv <[email-masked]>
Date: Sun, 16 May 2004 23:06:47 -0400

> "s/\(.*\)\/\(Fvwm[a-zA-Z]\+\).*/AddToMenu ModuleList \2 KillModule

Notice that you are using ``, to execute a command in subshell
instead of '' which may or may not matter to fvwm. Try with '' or ""
instead of `` in any case.

  - Parv

--

---

From: Mikhael Goikhman <[email-masked]>
Date: Mon, 17 May 2004 03:30:34 +0000

> instead of `` in any case.

Parv, why not just open FvwmConsole and verify your (wrong) theory? :)

Ok, let's analyze the situation. Suppose we all have GNU tools and this
command (pasted from the top of this message) indeed generates the menu:

  % ps x|grep Fvwm|sed -e "s/\\(.*\\)\\/\\(Fvwm[a-zA-Z]\\+\\).*/AddToMenu ModuleList \\2 KillModule \\2/"|sort|uniq

First, the choice of double quotes cause you double backslashes,
this is needless. Rewrite this shell command using a single quote:

  % ps x|grep Fvwm|sed -e 's/\(.*\)\/\(Fvwm[a-zA-Z]\+\).*/AddToMenu ModuleList \2 KillModule \2/'|sort|uniq

Now, you have 2 choices. First, to try to insert one of these commands
into PipeRead. To do this, you should escape all backslash using another
backspace (or maybe even replace each backslash with 4 backspaces, yes).
Dollars should sometimes be escaped too. You may play with it until you
get it correctly.

Another (preferable) choice is to create ~/bin/fvwm-menu-mymodulelist
script that contains our single line and just call it:

  + I PipeRead `fvwm-menu-mymodulelist`

Regards,
Mikhael.

---

From: Parv <[email-masked]>
Date: Sun, 16 May 2004 23:47:39 -0400

in message <[email-masked]>, wrote Mikhael
Goikhman thusly...
> > instead of '' which may or may not matter to fvwm. Try with ''
> > or "" instead of `` in any case.
> 

Good to know; i did not find any mention of
'`|back.?ticks|sub.?shell' in the above context in the manual.

As to use of FvwmConsole ... i tried to replicate OP's menu
generation there.  That takes to much time, here at least, to test
instead of update-configuration-restart-fvwm cycle.  I have given up
on the idea of using FvwmConsole any further for any reason for now.

  - Parv

--

---

From: Parv <[email-masked]>
Date: Sun, 16 May 2004 23:59:32 -0400

in message <[email-masked]>,
wrote Parv thusly...
> '`|back.?ticks|sub.?shell' in the above context in the manual.

Argh! Bear w/ me as i stop the above piece of misinformation from
myself.

In fvwm(1) page, section 'QUOTING', paragraph 3, '`' is apparently
listed as 'reverse single quote'.  In the same paragraph, it is
stated further that all three types of quotes--double quotes, single
quotes, backticks or reverse single quotes--are treated the same.

  - Parv

--