为什么autoconf脚本中的条件变量在变量前加"x"? [英] Why do conditionals in autoconf scripts prefix variables with "x"?

查看:79
本文介绍了为什么autoconf脚本中的条件变量在变量前加"x"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么autoconf脚本中的条件语句在变量前加"x"?例如,GNU提供的用于测试Boost的宏具有以下条件,例如

Why do conditional statements in autoconf scripts prefix their variables with "x"? For example, the macro provided by GNU to test for Boost has conditionals such as

if test "x$want_boost" = "xyes"; then

为什么未将其定义为:

if test "$want_boost" = "yes"; then

推荐答案

在某些早期的shell中,测试空字符串变量并不像现在这样容易,因此最好的选择是查看"x $ variable "等于"x".另外,由于显然使用了test,因此比尝试正确引用/转义'$ x!="y"'这样的序列更简单,而又不会失去理智和/或可移植性.

In some early shells, testing for an empty string variable wasn't as easy as it is now, so the best alternative was to see if "x$variable" was equal to just "x". Also, since that's apparently using test, that's simpler than trying to properly quote/escape sequences like '$x != "y"' without losing sanity and/or portability.

这篇关于为什么autoconf脚本中的条件变量在变量前加"x"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆