Subject: Still some problems with var expansion

From: Olivier Chapuis <[email-masked]>
Date: Tue, 16 May 2000 09:34:04 +0200

Hello,

I've got still some pbs with var expansion:
Try this:

AddToFunc test I $0

test "Module FvwmWinList"
[FVWM][ExecuteFunction]: <<ERROR>> No such command 'Module FvwmWinList'

However:

test "FvwmWinList"

work fine.

Olivier

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

---

From: Dominik Vogt <[email-masked]>
Date: Wed, 17 May 2000 18:48:34 +0200

> [FVWM][ExecuteFunction]: <<ERROR>> No such command 'Module FvwmWinList'

Of course.  In the first case, fvwm looks for a command named
"Module FvwmWinList" (without the double quotes) which does not
exist.  In my eyes fvwm's behaviour is correct.  I guess before
my fix this may have worked, but that was not intended.

Bye

Dominik ^_^

-- 
Dominik Vogt, Agilent Technologies, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/464-4596, fax: 07031/464-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Olivier Chapuis <[email-masked]>
Date: Thu, 18 May 2000 19:42:51 +0200

> my fix this may have worked, but that was not intended.

But like this we lost a functionality and I do not see what
we win. Moreover, now, I do not understand the logic in var
expansion: for me expansion have to be done and then fvwm have
to work as usual.

Let us give an example of use of this "old" functionality.
I've used this functionality in sample-95 with the function:

AddToFunc   SetBackground
# kill a possible Backer runing
+ I killModule FvwmBacker
# set the background
+ I $0
# save our state
+ I Exec echo "AddToFunc StartFunction I $0" > $FVWM_USERDIR/.start-Background

typical use is:

SetBackground FvwmBacker
SetBackground 'Exec exec xsetroot -solid Red1'
SetBackground 'Exec exec bggen blue magenta | xv -root -quit'
SetBackground 'Exec exec bggen black red yellow black grey60 | xv -root -quit'
SetBackground 'Exec exec xlock -nice 10 -inroot -mode braid'

Of course now except the first (and even it is natural for me to
use SetBackgroud 'Module FvwmBacker') nothing work!
How to fix this? by replacing "+ I $0" by "+ I $0 $1 ... $9"
and remove the above ' (and even the 4th command will not 
work as expected) ? Replacing "+ I $0" by + I PipeRead "echo $0"
work but this seems to me really crazy.

I imagine that there are other fixes and if the old functionality
does not reappear I will fix sample-95 ...

Olivier

---

From: [email-masked] (Paul D. Smith)
Date: 18 May 2000 13:59:36 -0400

%% Olivier Chapuis <[email-masked]> writes:

  oc> How to fix this? by replacing "+ I $0" by "+ I $0 $1 ... $9"
  oc> and remove the above ' (and even the 4th command will not 
  oc> work as expected) ? Replacing "+ I $0" by + I PipeRead "echo $0"
  oc> work but this seems to me really crazy.

Maybe we should implement the shell's $*.

Then you could have:

  ...
 + I Exec echo "AddToFunc StartFunction I $*" > $FVWM_USERDIR/.start-Background
  ...

 SetBackground FvwmBacker
 SetBackground Exec exec xsetroot -solid Red1
 SetBackground Exec exec bggen blue magenta | xv -root -quit
 SetBackground Exec exec bggen black red yellow black grey60 | xv -root -quit
 SetBackground Exec exec xlock -nice 10 -inroot -mode braid

and have it DTRT.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 19 May 2000 02:00:50 +0300

> Maybe we should implement the shell's $*.

Yes, we should have it regardless of other issues.
And $@ (quoting every parameter, not only separating) would be nice too.

>  SetBackground Exec exec xlock -nice 10 -inroot -mode braid

This only fixes simple cases, when you need one multiple-word parameter,
but still with your suggestion there is no way to emulate:

  SetBackground "Exec xsetroot -solid Red1" "Exec xv -root -quit b.jpg"

(and the function will decide which one to use accourding to the state).
Note, this functionality worked for a long time. This is not a theoretical
discussion, we use complex functions, like this, in fvwm-themes a lot.

I agree with Olivier, parameters should be expanded, like in shell, before
command execution. If one wants to treat a parameter in the first place
specially like it is done now (for a short time), he can use quotes, "$0".

Regards,
Mikhael.

---

From: [email-masked] (Paul D. Smith)
Date: 18 May 2000 21:02:01 -0400

>> Maybe we should implement the shell's $*.

  mg> Yes, we should have it regardless of other issues.  And $@
  mg> (quoting every parameter, not only separating) would be nice too.

Actually, $@ == $*.  You have to write "$@" (with quotes) to get the
special behavior.  Don't ask me.

  mg> This only fixes simple cases, when you need one multiple-word parameter,
  mg> but still with your suggestion there is no way to emulate:

  mg>   SetBackground "Exec xsetroot -solid Red1" "Exec xv -root -quit b.jpg"

I'm not very clear on this.  How does this expand now, in the new way?

I think it would be useful if someone wrote down exactly how these used
to work, and how they work now.  Or, at least how they work now.  The
man page just says they expand to the positional params but doesn't say
how quoting the parameters is handled.  Am I missing this somewhere?

Then, we can talk about how to handle this case.  Quoting and parameter
expansion is actually pretty tricky to get right so it's both usable and
useful, in my experience.

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 19 May 2000 06:13:53 +0300

> I'm not very clear on this.  How does this expand now, in the new way?

Depends on the function definition, suppose: AddToFunc SetBackground I $1

This will work differently in the new and the old ways. If you put quotes
around $1, it will work the same, but it will never DTRT in the new way.

> how quoting the parameters is handled.  Am I missing this somewhere?

You should write many example functions to understand all issues.
There is a "compile" time line processing (actually 2, in ExecuteFunction
and one is in AddToFunction) and a run time processing (ExecuteFunction).
I think, a user who wants/needs to understand can do it by "try and see".
Here is how $0 - $9 are expanded in functions (only 10 args supported).

The old way was exactly like shell does. Just substitude all $0 - $9 found
anywhere in the function line at run time and execute the processed line.

The new way is that you know at compile time (function definition time)
how the function line will be divided into parameters (quoted words) and
you have no way to change this at run time.

The old and new ways work the same if you don't pass parameters with
spaces and quotes inside (i.e. for most of simple functions).

Example function line:

+ I $0$1 "$2 $3" $4;$5 $6

The new way: there will be 4 words in the expanded line.
The old way: (I, like shell, respect my user, not restrict), my guess -
4 words, but may be 1 or 20, I can't say anything before seeing $0 - $6.

While one can find the new way good, it is in fact limited enough.
The whole point is that it is easy to emulate the new way using the
old one (add quotes and don't pass 'str"ing'), but not vice versus.

Regards,
Mikhael.

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 19 May 2000 11:04:43 +0200

> SetBackground 'Exec exec xlock -nice 10 -inroot -mode braid'

Try

  SetBackground \'Exec exec xsetroot -solid Red1\'

or

  SetBackground "'Exec exec xsetroot -solid Red1'"

I have to think about this... but not before Monday.

Bye

Dominik ^_^

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 29 May 2000 22:28:40 +0200

> Maybe we should implement the shell's $*.

Done.

Bye

Dominik ^_^

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