Coercions to boolean

It almost beaten to death

don’t use command substitution and subshell because you subshell a subshell already. You can see in the code below

do shell script "echo `(echo $BASH_SUBSHELL)`" -->2

A bit unnecessary overhead IMO. so the correct code(s) would be:

do shell script "echo `echo a;echo b;echo c`" --old bourne shell substitution (obsolete)
#or
do shell script "echo $(echo a;echo b;echo c)"--not supported in older bash

:slight_smile:

As for the cost of spawning an extra shell; I don’t know exactly how much memory that takes, but I am totally sure that it uses a lot less than opening a new tab in Safari!

Try this:

set a to (do shell script "echo $(echo a;echo b;echo c | cat -n)")

It is just something to consider, that the do shell script, collects the output, like you see it in the terminal, it doesn’t necessarily redirect to the next command as a whole, that was the idea of using the sub shell in the first place, to avoid making temporary files for collating and such.

By the way. When you have to do a sudo command, and doesn’t have adminstrative rights on your account, then do shell script with administrator privileges works great! :slight_smile: