|
今天emerge sudo时遇到一个奇怪的shell语法错误
USE flag参考- miqiur@miahiu ~ $ emerge -pv sudo
- These are the packages that would be merged, in order:
- Calculating dependencies... done!
- [ebuild R ] app-admin/sudo-1.7.2_p4 USE="ldap pam -offensive (-selinux) -skey" 0 kB
- Total: 1 package (1 reinstall), Size of downloads: 0 kB
复制代码 实际运行时输出一行错误提示- ./configure: line 21855: test: =: unary operator expected
复制代码 这是在configure时报的错,但错误被忽略了,emerge成功。完了之后我找到源码包/usr/portage/distfiles/sudo-1.7.2p4.tar.gz,cp到~/tmp下解压,并且确定emerge时没有添加patch。于是我找到configure源文件的第21855行- if test ${with_skey-'no'} = "yes"; then
复制代码 如果条件成立会执行后面跟着的50多行代码
- if test ${with_AFS-'no'} = "yes"; then
- # looks like the "standard" place for AFS libs is /usr/afsws/lib
- AFSLIBDIRS="/usr/lib/afs /usr/afsws/lib /usr/afsws/lib/afs"
- for i in $AFSLIBDIRS; do
- if test -d ${i}; then
- if test X"$with_rpath" = X"yes"; then
- SUDO_LDFLAGS="${SUDO_LDFLAGS} -L$i -R$i"
- else
- SUDO_LDFLAGS="${SUDO_LDFLAGS} -L$i"
- fi
- if test X"$blibpath" != X"" -a "SUDO_LDFLAGS" = "SUDO_LDFLAGS"; then
- blibpath_add="${blibpath_add}:$i"
- fi
- FOUND_AFSLIBDIR=true
- fi
- done
- if test -z "$FOUND_AFSLIBDIR"; then
- { echo "$as_me:$LINENO: WARNING: Unable to locate AFS libraries, you will have to edit the Makefile and add -L/path/to/afs/libs to SUDO_LDFLAGS or rerun configure with the --with-libpath options." >&5
- echo "$as_me: WARNING: Unable to locate AFS libraries, you will have to edit the Makefile and add -L/path/to/afs/libs to SUDO_LDFLAGS or rerun configure with the --with-libpath options." >&2;}
- fi
- # Order is important here. Note that we build AFS_LIBS from right to left
- # since AFS_LIBS may be initialized with BSD compat libs that must go last
- AFS_LIBS="-laudit ${AFS_LIBS}"
- for i in $AFSLIBDIRS; do
- if test -f ${i}/util.a; then
- AFS_LIBS="${i}/util.a ${AFS_LIBS}"
- FOUND_UTIL_A=true
- break;
- fi
- done
- if test -z "$FOUND_UTIL_A"; then
- AFS_LIBS="-lutil ${AFS_LIBS}"
- fi
- AFS_LIBS="-lkauth -lprot -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err ${AFS_LIBS}"
- # AFS includes may live in /usr/include on some machines...
- for i in /usr/afsws/include; do
- if test -d ${i}; then
- CPPFLAGS="${CPPFLAGS} -I${i}"
- FOUND_AFSINCDIR=true
- fi
- done
- if test -z "$FOUND_AFSLIBDIR"; then
- { echo "$as_me:$LINENO: WARNING: Unable to locate AFS include dir, you may have to edit the Makefile and add -I/path/to/afs/includes to CPPFLAGS or rerun configure with the --with-incpath options." >&5
- echo "$as_me: WARNING: Unable to locate AFS include dir, you may have to edit the Makefile and add -I/path/to/afs/includes to CPPFLAGS or rerun configure with the --with-incpath options." >&2;}
- fi
- AUTH_OBJS="$AUTH_OBJS afs.o"
- fi
复制代码 但因为这个错误,导致这些代码都没有执行。
但我发现这个错误很奇怪,在交互式bash和交互式sh环境下都无法重现,要想出现这个错误必须是这种形式的代码- miqiur@miahiu ~/tmp $ test = "yes"
- -bash: test: =: unary operator expectedtest
复制代码 也就是说configure脚本中的- test ${with_skey-'no'} = "yes"
复制代码 被解释成但是无论在bash里还是在sh里,不管with_skey变量是否初始化,长度是否为0,${with_skey-'no'}都会被赋值为一个非空非零长的值。
所以我对这个错误一直无法理解。
请教各位,这是为何。
是否和shell的设置有关?
附上configure脚本的前30行,包含一些shell的设置,脚本的其它地方也有,但没细看,太长了
- miqiur@miahiu ~/tmp/sudo/sudo-1.7.2p4 $ head -30 configure
- #! /bin/sh
- # Guess values for system-dependent variables and create Makefiles.
- # Generated by GNU Autoconf 2.61 for sudo 1.7.2p4.
- #
- # Report bugs to <http://www.sudo.ws/bugs/>.
- #
- # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
- # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
- # This configure script is free software; the Free Software Foundation
- # gives unlimited permission to copy, distribute and modify it.
- ## --------------------- ##
- ## M4sh Initialization. ##
- ## --------------------- ##
- # Be more Bourne compatible
- DUALCASE=1; export DUALCASE # for MKS sh
- if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
- else
- case `(set -o) 2>/dev/null` in
- *posix*) set -o posix ;;
- esac
- fi
复制代码
我系统上的/bin/sh是链接到bash的- miqiur@miahiu ~/tmp/sudo/sudo-1.7.2p4 $ readlink -f /bin/sh
- /bin/bash
复制代码 |
|