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

Re: Shell script anomaly



begin  Alex Malinovich  quotation:

> I'm sure that I might be missing something obvious here, but after a few
> hours I still haven't figured it out. I'm writing a script to detect
> whether xscreensaver is running and activate it if it is. If not, it
> launches the daemon first and then activates. From the command line, the
> following returns the correct exit codes:
> 
> if ps -A |grep -q "[x]screensaver"; then xscreensaver-command -activate
> else xscreensaver& xscreensaver-command -activate; fi
> 
> However, if I put that exact line into a shell script and run it, the if
> ALWAYS gets evaluated as true. Any ideas?

I cannot reproduce your symptoms. Whether I type your code in at the
shell prompt or run it in a script, it always behaves correctly.

You don't say what shell you're using (or what version); my tests were
performed using the version of bash 2.05a.0(1)-release from the Sid
package bash_2.05a-11.

Craig

Attachment: pgpDdt7aSI7oq.pgp
Description: PGP signature


Reply to: