1

I am modifying a configure.ac for use with AutoConf: http://mathpad.wikidot.com/acousto-configure-ac

The script points out that it needs to run on darwin, solaris, cygwin and linux.

I assume this is why it uses an arcane method of comparing strings:

foo="1"
if test "x$foo" != "x0"; then

This double negative makes it difficult to read through the code. Can I clean it up?

How might I implement a string comparison macro:

if STR_EQUAL( $foo, "1" ); then

Or:

if TRUE( $foo ); then

And this is the best way of solving the problem?

EDIT: apparently this script is written in M4 http://www.gnu.org/software/m4/manual/m4.html

4

3 に答える 3

1

を使用exprすると、十分に移植可能 (および読み取り可能) である必要があります。

if expr $foo; then
  #do something
fi

からの出力を削除したい場合は、次のexprように言います。if expr $foo >/dev/null; then

于 2014-01-16T12:17:51.753 に答える