TVアニメ「刀使ノ巫女」第3弾PV
アニメ『刀使ノ巫女』
1話目から超展開するので、ついていけず置いてきぼりにされてしまったのですが、2話最後~3話見てからようやく話が理解でき、これは面白いのかも、ともう一度1話から見始めました。登場人物の顔も覚えた後なので、一回目はつまらなかったプロローグのシーンも楽しめました。 生徒たちのトーナメント試合も改めて見ると、テンポが良くて、これはこれで良いかも。
シリアスな展開で、ノーストレスのゆるゆるアニメが好きな私としては、死人は出てほしくないのですが、 斬られても死なない「うつし」と呼ばれてる術を使ってるので安心です。このまま誰も死なないでくれ、と祈りつつ視聴していこうと思います。
今回は、刀つながりでcutコマンドです。
おそらく使ったことがない-cオプション。何に使うのでしょうか。manコマンドを見ると、-bと-cオプション、似たような説明が書かれています。
takk@deb9:~$ man cut
CUT(1) ユーザーコマンド CUT(1)
名前
cut - ファイルの各行から一部分を取り除く
~省略~
-b, --bytes=LIST
バイトで数えた LIST を選択する
-c, --characters=LIST
文字で数えた LIST を選択する
-d, --delimiter=DELIM
フィールドの区切り文字として TAB の代わりに DELIM を使用する
~省略~
こんな時はソースを確認するのが一番早いです。coreutilsにあるので落としてきます。
takk@deb9:~$ apt-get source coreutils takk@deb9:~$ cd coreutils-8.26
ライセンスを確認する癖をつけるため必ず冒頭部を確認します。まあGNUなので毎回同じなのですが。
takk@deb9:~/coreutils-8.26$ sed '/#inc/Q' src/cut.c /* cut - remove parts of lines of files Copyright (C) 1997-2016 Free Software Foundation, Inc. Copyright (C) 1984 David M. Ihnat This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Written by David Ihnat. */ /* POSIX changes, bug fixes, long-named options, and cleanup by David MacKenzie <djm@gnu.ai.mit.edu>. Rewrite cut_fields and cut_bytes -- Jim Meyering. */ takk@deb9:~/coreutils-8.26$
さっそく-cオプションの使い方を調べます。getoptでオプション解析しているところを見れば良いので、case ‘c’:周辺を抽出します。
takk@deb9:~/coreutils-8.26$ grep 'case.*c.:' -C5 src/cut.c
while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, NULL)) != -1)
{
switch (optc)
{
case 'b':
case 'c':
/* Build the byte list. */
if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified"));
operating_mode = byte_mode;
spec_list_string = optarg;
takk@deb9:~/coreutils-8.26$
ズバリ、bオプションと同じですね。何故別のオプションとして用意されているのでしょう。
manの方ではなく、infoの方でコマンドの説明を読んでみます。
takk@deb9:~$ info cut
~省略~
‘-c CHARACTER-LIST’
‘--characters=CHARACTER-LIST’
Select for printing only the characters in positions listed in
CHARACTER-LIST. The same as ‘-b’ for now, but internationalization
will change that. Tabs and backspaces are treated like any other
character; they take up 1 character. If an output delimiter is
specified, (see the description of ‘--output-delimiter’), then
output that string between ranges of selected bytes.
~省略~
どうやらとりあえず-bオプションと同じになってるみたいです。でも、いずれ国際化されたら、本当に文字毎にcutすることができるようになるんでしょうね。


コメント