为什么在 MacOS 上 unexpand 可以在没有“-a”参数的情况下更改内部空间?
Why can unexpand on MacOS change internal spaces without the "-a" argument?
unexpand
的手册页指出:
By default, only leading blanks and tabs are reconverted to maximal strings of tabs.
然而,它似乎肯定也在转换内部空白:
echo " HELLO THERE" | unexpand -t 2 | tr '\t' '_'
产量
_HELLO_ THERE
而不是预期的
_HELLO THERE
如果我包含 -a
选项,这是我期望的输出,但无论有无该选项,输出都是相同的。
来自 the POSIX spec,重点补充:
When -t
is specified, the presence or absence of the -a
option shall be ignored; conversion shall not be limited to the processing of leading <blank>
characters.
expand
的 GNU coreutils 版本(但不是 Apple 使用的 BSD 版本)有一个 --first-only
选项可以抵消这种行为。
unexpand
的手册页指出:
By default, only leading blanks and tabs are reconverted to maximal strings of tabs.
然而,它似乎肯定也在转换内部空白:
echo " HELLO THERE" | unexpand -t 2 | tr '\t' '_'
产量
_HELLO_ THERE
而不是预期的
_HELLO THERE
如果我包含 -a
选项,这是我期望的输出,但无论有无该选项,输出都是相同的。
来自 the POSIX spec,重点补充:
When
-t
is specified, the presence or absence of the-a
option shall be ignored; conversion shall not be limited to the processing of leading<blank>
characters.
expand
的 GNU coreutils 版本(但不是 Apple 使用的 BSD 版本)有一个 --first-only
选项可以抵消这种行为。