Problem with Bash-4 and $(command) syntax

Jerry gesbbb at
Thu Mar 12 07:25:34 PDT 2009

I just updated from Bash-3.x to Bash-4.0. There appears to be a problem
with the way Bash-4 interprits the following.

This works fine on Bash-3.x:
#!/usr/bin/env bash


if $( which gpg2 ); then
   printf "gpg2 located"
However, under Bash-4, it fail with this error message:

./ command substitution: line 6: syntax error near unexpected
token `)' ./ command substitution: line 6: ` which gpg2 )'

I have several scripts that use the $(command) syntax and they are all
failing now. I have replaced that syntax with the older "`" tics method.

Is this a known problem with Bash-4? I have not been able to find
anything about it on the Bash site.

gesbbb at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list