
最新版のmacOS、「macOS Sonoma」でgrepコマンドが壊れている事がわかりました(Hacker News)。
Appleの開発者向けフォーラムに投稿された情報によると、一致箇所のみを出力する"-o"オプションを付けgrep -oを実行した場合に、特定のパターンでアサーション失敗(assertion fails)が発生し、abortする模様。
printf '%s' '3.2.57(1)-release' | grep -o '[0-9.]*' Assertion failed: (advance > 0), function procline, file util.c, line 732. zsh: done printf '%s' '3.2.57(1)-release' | zsh: abort grep -o '[0-9.]*'
再現可能な最小パターンとしてprintf '%s' 'a' | grep -o 'b*'が提示されています。
# fails printf '%s' 'a' | grep -o 'b*' # works printf '%s' 'a' | grep -o 'b' # also works (note: without -o flag) printf '%s' 'a' | grep 'b*'
アサーション失敗が発生している、該当のソースコードも探し出されていて、別の不具合に対処するために新たなバグが入ったのではないかと指摘されています。
				/*
				 * rdar://problem/86536080 - if our first match
				 * was 0-length, we wouldn't progress past that
				 * point.  Incrementing nst here ensures that if
				 * no other pattern matches, we'll restart the
				 * search at one past the 0-length match and
				 * either make progress or end the search.
				 */
				if (pmatch.rm_so == pmatch.rm_eo) {
					if (MB_CUR_MAX > 1) {
						wchar_t wc;
						int advance;
						advance = mbtowc(&wc,
						    &pc->ln.dat[nst],
						    MB_CUR_MAX);
						assert(advance > 0);
						nst += advance;
					} else {
						nst++;
					}
				}
Hacker Newsでは、macOSのBSDユーザーランドユーティリティは超時代遅れであることに注意しなければならないとの指摘も行われています。

 
			 
			 
			 
			 
			 
			 
			