[Top][All Lists]

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

Re: [RP] Error return codes

From: Mike Meyer
Subject: Re: [RP] Error return codes
Date: Tue Nov 20 20:32:02 2001

Ben Leslie <address@hidden> types:
> Another question. Would is be possible for ratpoison to pass
> back error commands when using the -c option.
> I would like to do:
> ratpoison -c "select mutt"
> echo $?
> and if there is not "mutt" window it would
> return some non zero value. That way in a script
> I would be able to then recover from this problem.
> (ie: start mutt and change focus to it).
> This seems to need hacking send_command/
> recieve_command_result in communications.c and ensuring
> that all commands in actions.c return error codes
> when they should.
> What do other people think?

I think it's a good idea, but it takes more work than you've
described. The catch is that the two ratpoisons are communicating via
strings in X resources. The things in actions.c return those strings
or NULL. There are already plans in place to make many of those that
currently return NULL return meaningful strings. I've got patches
that do that, and even have a script that uses that capability.

So you need to either 1) find another place to stash return values, or
2) provide a mechanism to encode errors in the strings that won't
collide with legitimate return values.

I think that in the few cases it could be really useful, there are
straightforward workarounds. For instance, the script that Doug
references greps the output of "ratpoison -c windows" then either does
the select or runs a command. I've attached the latest version.

Yes, I know that ratmenu examples uses the old ratmenu. I still don't
have sources to the new one....


# Ask ratpoison if the first argument exists as a window title. If so,
# select that window.  If not, then try running the rest of the arguments
# if they exist. If they don't exist, try running the first argument. Example
# usage with ratmenu:
# ratmenu "emacs:ratpoison-get-a emacs" "jpilot:ratpoison-get-a j-pilot jpilot"
# Note that the window title test is case-insensitive.

if [ -n "$1" ]
    echo "usage: $0 window [command ...]"
    exit 0

if [ $# -ge 1 ]

if (ratpoison -c "windows %t" | grep -qi $window)
    ratpoison -c "select $window"
    exec $command

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]