Using result with a calculated if

I know this is possible

if (do shell script "echo \"hello how are you\"") contains "hello" then
	set x to (do shell script "echo \"hello how are you\"")
end if

But what I want to do is more along the lines of this

if (do shell script "echo \"hello how are you\"") contains "hello" then set x to result

The idea here is kepping the shell call down to 1 instance. And yes I know I could also do this

set y to (do shell script "echo \"hello how are you\"")
if y contains "hello" then set x to y

but I like 1 liners :smiley:

You can use a tell block:

tell (do shell script "echo 'hello how are you?'") to if it contains "hello" then set x to it

That’s it. AppleScript has just lost the right to be called “English-like”.

:lol:

Some obvious comments that nevertheless need to be made, I suppose:

  1. “English-like” doesn’t mean “English”.
  2. “English” means different things to different people.
  3. Liking one-liners is James’s problem, not AppleScript’s.

Yeah I pretty much have a sickeness of sorts LOL