我们正试图找到一种方法来制作一个几乎适用于所有 Unix 兼容程序的 GNUmakefile。我们正在使用,egrep
但在 MinGW 上失败了。我们切换到grep -E
是因为它是Posix,但测试表明它在 Solaris 11 上失败了。
makefile 中的典型用法是:
GREP ?= grep
...
IS_X86 := $(shell uname -m | $(GREP) -v "x86_64" | $(GREP) -i -c -E "i.86|x86|i86")
IS_X64 := $(shell uname -m | $(GREP) -i -c -E "(_64|d64)")
Run Code Online (Sandbox Code Playgroud)
结果是:
grep: illegal option -- E
Usage: grep [-c|-l|-q] -bhinsvw pattern file . . .
grep: illegal option -- E
Usage: grep [-c|-l|-q] -bhinsvw pattern file . . .
...
Run Code Online (Sandbox Code Playgroud)
我在 Posix中看不到哪里-E
和-F
是可选的(也许我错过了)。我在 Stack Overflow 上找到了 Solaris 和 POSIX 之间的差异,但它指出,“Solaris 有一套完整的 POSIX 接口......”。
为什么 Solarisgrep
无法消费-E
?除了切换到 ,还有没有办法在 Solaris 上使用正则表达式支持egrep
?
我只是在 Solaris 11.3 机器上设置了一个新的测试帐户,以确保我没有污染环境。
该帐户已添加:
# useradd -d /export/home/test -m -s /bin/ksh -c "Testing Accoung" test
80 blocks
Run Code Online (Sandbox Code Playgroud)
PATH
登录后检查:
test@solaris:~$ echo $PATH
/usr/bin:/usr/sbin
Run Code Online (Sandbox Code Playgroud)
公用事业
如果 POSIX.2、POSIX.2a、XPG4、SUS 或 SUSv2 要求的行为与历史 Solaris 实用程序行为冲突,则该实用程序的原始 Solaris 版本不变;中提供了符合标准的新版本
/usr/xpg4/bin
。对于希望利用 POSIX.2、POSIX.2a、XPG4、SUS 或 SUSv2 功能的应用程序,PATH
(sh
或ksh
) 或path
(csh
) 环境变量应设置/usr/xpg4/bin
在找到这些规范指定的实用程序的任何其他目录之前,如/bin
,/usr/bin
,/usr/ucb
,和/usr/ccs/bin
。
如果您必须使用扩展正则表达式,请/usr/xpg4/bin
尽早设置PATH
并使用grep -E
.
归档时间: |
|
查看次数: |
2110 次 |
最近记录: |