SmartOS(SunOS)で「xargs -n」が他の実装とは異なる動作をするのはなぜですか?

SmartOS(SunOS)で「xargs -n」が他の実装とは異なる動作をするのはなぜですか?

-nSmartOS(Solarisのようです)のxargsオプションは、私が出会った他のバージョンのxargsとは異なる動作をするようです。

たとえば、

組み込み/usr/bin/xargs(奇妙な動作):

# printf 'one\0two\0three' | xargs -0 -I{} -n 1 echo "- {}"
- {} one
- {} two
- {} three

GNU Findutils /opt/local/bin/xargs (予想される動作):

# printf 'one\0two\0three' | /opt/local/bin/xargs -0 -I{} -n 1 echo "- {}"
- one
- two
- three

MacOS、NetBSD、およびCentOSのXargsは、すべて前の例と同じように動作します。 SmartOS xargsはどう違いますか?

SmartOS xargsのマンページから:

   -n number
                  Invokes utility using as many standard input arguments
                  as possible, up to number (a positive decimal integer)
                  arguments maximum. Fewer arguments are used if:

                      o      The command line length accumulated exceeds
                             the size specified by the -s option (or
                             {LINE_MAX} if there is no -s option), or

                      o      The last iteration has fewer than number, but
                             not zero, operands remaining.

Gnu Findutils xargsのマンページから:

   -n max-args, --max-args=max-args
          Use at most max-args arguments per command line.  Fewer than max-args arguments will be used if the size (see the -s option) is  exceeded,  un‐
          less the -x option is given, in which case xargs will exit.

私はシェルスクリプトを移植するときにこれらの違いを見つけましたが、なぜ動作が異なるのかを知っている人がいるのだろうか。

ベストアンサー1

-Iとオプションを組み合わせることはできません-n。これは基準説明する:

-I-Lオプションは相互に-n排他的です。コマンドラインに複数のものがある場合、一部の実装は指定された最後のオプションを使用し、他の実装ではオプションの組み合わせを異なる方法で処理します。

また、見ることができますこれそしてこれ

おすすめ記事