Subject: FVWM: Re: [HELP]PipeRead Strange Error Message

From: [email-masked]
Date: Mon, 17 May 2004 11:21:18 +0800

In your mail:
> >
> >  + I PipeRead `ps x|grep Fvwm|sed -e
> > "s/\\(.*\\)\\/\\(Fvwm[a-zA-Z]\\+\\).*/AddToMenu ModuleList \\2 KillModule
> > \\2/"|sort|uniq`
> 
> 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
the fucntion looks like:
Now DestroyFunc funcModuleList
AddToFunc funcModuleList
 + I PipeRead 'ps x|grep Fvwm|sed -e "s!\\(.*\\)/\\(Fvwm[a-zA-Z]\\+\\).*!AddToMenu
ModuleList \\2 KillModule \\2!"|sort -u'

--
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: [email-masked]
Date: Mon, 17 May 2004 11:23:30 +0800

In your mail:
> > 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"
> 
> 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
Actually, fvwm treat `` '' "" the same way.
But Thank you anyway!

---

From: [email-masked]
Date: Mon, 17 May 2004 11:55:40 +0800

In your mail:
>From: Mikhael Goikhman <[email-masked]>
>Reply-To: 
>To: [email-masked]
>Subject: Re: FVWM: Re: [HELP]PipeRead Strange Error Message
>
>On 16 May 2004 23:06:47 -0400, Parv wrote:
> > 
> > in message <[email-masked]>,
> > wrote [email-masked] thusly...
> > >
> 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.
>
Great tips!
But:
AddToFunc funcModuleList
 + I PipeRead `ps x|grep Fvwm|sed -e 's!\\(.*\\)/\\(Fvwm[a-zA-Z]\\+\\).*!AddToMenu
ModuleList \\2 KillModule \\2!'|sort -u`
already works in the popup menu.
I am just confused by the error messages in ~/.xsession-errors:
[FVWM][__execute_function]: <<ERROR>> No such command '15958'

Then I try starting 'fvwm -D' for debugging and know that
'`ps x|grep Fvwm|sed -e 's!\\(.*\\)/\\(Fvwm[a-zA-Z]\\+\\).*!AddToMenu ModuleList
\\2 KillModule \\2!'|sort -u`'
is rendered by fvwm as:
'15958 ?        R      0:00 sh -c ps x|grep Fvwm|sed -e
's!\(.*\)/\(Fvwm[a-zA-Z]\+\).*!AddToMenu ModuleList \2 KillModule \2!'|sort -u'

BTW: I am using fvwm-snap-20040516

---

From: [email-masked]
Date: Mon, 17 May 2004 16:35:26 +0800

In your mail:
>From: Rainer Koehler <[email-masked]>
>Reply-To: 
> Doesn't this look like a line of ps-output to you? ;-)
>

That's why I found it weird. 

> When you grep for something in ps-output, you usually also pick up the
> process of the grep itself (since it's argument is exactly what it's
> looking for).  In this case, it picks up the sh-process created by
> fvwm.
> 
> I know two ways to get around that:
> - grep for a regexp like '[F]vwm' (because it doesn't match itself)
> - or add a 'grep -v grep' to the command line
>
 
Thank you! `grep -v grep' solved the problem!
Now I know the best way to test out PipeRead command stream is:

% exec COMMAND

> BTW, I would follow Mikhael's advice and put all that into a separate
> shell-script.  Life is much easier if reduce the number of quotes,
> backslashes etc.  And a script is much easier to debug because you can
> just call it from a shell-prompt.
>

I agree.