[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RP] Patch for frames et al...

From: Mike Meyer
Subject: Re: [RP] Patch for frames et al...
Date: Fri Nov 2 18:02:02 2001

Ryan Yeske <address@hidden> types:
> Mike Meyer <address@hidden> writes:
> > Ryan Yeske <address@hidden> types:
> > > I'm not sure I understand.  You want to have it look like this:
> > > 
> > > $ ratpoison --command defwinfmt
> > > defwinfmt = %n %s %w
> > > Why?
> > Because that's easy for scripts to parse and makes sense to people as
> > well. That's compared to the current behavior of having it say
> > "Default windows format is %n %s %w" which is more than most scripts
> > need, or just saying "%n %s %w", which isn't quite enough information
> > for people.
> Ok, I didn't understand that the suggestion was in comparison to an
> even _more_ verbose output.  Reading the original message again makes
> that clear :)
> However, my argument is that there should be _nothing_ other than just
> the value of the variable printed when called non-interactively.
> Consider this script:
> ,----
> | #!/bin/sh
> | 
> | # save the background color
> | oldbgcolor=`ratpoison --command=defbgcolor`;
> | 
> | # print a message with a green background
> | ratpoison --command="defbgcolor green";
> | ratpoison --command="echo this is with a green background";
> | 
> | # restore the old background color
> | ratpoison --command="defbgcolor $oldbgcolor";
> `----
> If `ratpoison --command=defbgcolor' outputs anything other/more than
> just the name of the color then this script would not work.

So fix the script. Just change the first line to:
oldbgcolor=`ratpoison -command=defbgcolor | sed 's/.*= //'`

One of the goals when I rewrote all the commands to output values was
making the commands not need to change their behavior depending on
whether they are interactive or not. To do that means the output needs
to be verbose enough for humans reading it interactively, but regular
enough that scripts can pull the value out.

How about a third alternative: the commands output the command that
would set the variable to it's current value? That would make your
script even easier, is understandable by humans, and it's still easy
to pull out just the value if you wanted that for some reason.

Mike Meyer <address@hidden>                     http://www.mired.org/home/mwm/
Q: How do you make the gods laugh?              A: Tell them your plans.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]