10/31/2011

ミルクラッパー Shibori さんのラップを聴いて、ミルキーハイ!

夏休みにバスの中で読んだ雑誌で知った、Shibori さんのラップ。
僕は特に「酪農」が好きで、「牛舎」を連発するところが気に入ってます!






10/30/2011

FreeBSD の yes(1) を読んでみる。

yes(1) は引数で渡された文字列か、"y" を繰り返し表示するコマンド。
お勉強のために、FreeBSD の HEAD にある rev. 1.6 を読んでみる。

プログラムの本体はすっごいすっきり。無駄がない。
int
main(int argc, char **argv)
{
 if (argc > 1)
  while (puts(argv[1]) != EOF)
   ;
 else
  while (puts("y") != EOF)
   ;
 err(1, "stdout");
 /*NOTREACHED*/
}
puts(3) は "return a nonnegative integer on success and EOF on error." だそう。err(3) はエラーメッセージを標準エラー出力に出してくれる。

yes.c の先頭のほうの、#ifndef lint から始まるあたりについては、openbsd-newbies って ML で Chris Palmer さんがやさしく教えてくれるう。
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1987, 1993\n\
 The Regents of the University of California.  All rights reserved.\n";
#endif /* not lint */

#ifndef lint
#if 0
static char sccsid[] = "@(#)yes.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$FreeBSD: src/usr.bin/yes/yes.c,v 1.6 2010/12/11 08:32:16 joel Exp $";
#endif
#endif /* not lint */
この copywrite とか rcsid はバイナリに埋め込んでおくってことだと思ったんだけど....strings(1) とかで見えないなあ。。ま、また、なんかのときに調べてみよ。

ところで、
$ yes a b c
を FreeBSD の上でやると、"a" が連続して表示されるんだけど、cygwin 上だと、"a b c" が連続されて表示される。今度、GNU coreutils の yes(1) を読んでみよう