Why do conditionals in autoconf scripts prefix variables with “x”?

主宰稳场 提交于 2019-11-28 00:42:17

问题


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

Why is this not defined as:

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

回答1:


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.



来源:https://stackoverflow.com/questions/11265847/why-do-conditionals-in-autoconf-scripts-prefix-variables-with-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!