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

Re: scripting gnuclient and emacs for mutt [ was: emacsclient -nw]

On Thu, Nov 20, 2003 at 10:49:45AM -0500, Matt Price wrote:
> is it possible in bash to test whether a comand has actually worked?
> I feel like I've seen such tests, but I tried one and can't make it
> work for me: 
> #! /bin/bash
> if [ 'gnuclient -q $*' ]; then 

That's definitely wrong: 'gnuclient -q $*' is just a string, not "call
this program". Also, there's no need to use [ ] (a.k.a. /usr/bin/test)
for this purpose. Just check the program's exit status directly:

  if gnuclient -q $*; then
    # success
    # failure

Alternatively, you can look at $? for the command's exit status.


Colin Watson                                  [cjwatson@flatline.org.uk]

Reply to: