ときどきの雑記帖 RE* (新南口)
ONE DAY IN THE LIFE OF IVAN DEJAVU
新九郎、奔る!
今週発売のスピリッツ掲載の回で個人的に 「グッと来た」 セリフがあった。
ちょっと趣(ってなんですか)が違うけど センゴク外伝 桶狭間戦記 にもそういうセリフが あったなあと思い出したり。
glob bash 6
GLOBIGNORE
glob_filename (temp, gflags)
から返されたresults
に対してignore_glob_matches (results);
のようなことをしているけど、これは GLOBIGNORE で一時的に*(ワイルドカード)のglob 展開を止める。 - それマグで! に書かれているようなことを行うためなので、
と書いたけど、見落としと勘違いがあったので補足。
shell_glob_filename
の問題の部分を三度。
char *temp, **results;
int gflags, quoted_pattern;
noglob_dot_filenames = glob_dot_filenames == 0;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME|qflags);
gflags = glob_star ? GX_GLOBSTAR : 0;
results = glob_filename (temp, gflags);
free (temp);
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results, 1); /* posix sort */
else
{
FREE (results);
results = (char **)&glob_error_return;
}
}
return (results);
この関数では何をやっているかと言うと、
- quote_string_for_globbing glob本体を呼び出す前の前処理
- glob_filename glob本体(たぶん)
- should_ignore_glob_matches が非0を返したら ignore_glob_matches(無視すべきパターンにマッチしたものを取り除く)
- 3の結果が空でなければ strvec_sort
- 3の結果が空だったら results = (char **)&glob_error_return;
ということで、結果としてはglobを抑制したかのように見えるけど、
実はわざわざ作ったglob結果を
(すべてにマッチする*
というパターンで)「無視」することによって空にする。
という(遠回りな)ことをしている。
だから、glob結果が空になったときの動作を変えると
kbk@toybox4:~$ echo *
.bash_history .bash_logout .bashrc .landscape .motd_shown .profile .sudo_as_admin_successful .viminfo .vscode-server a.txt
kbk@toybox4:~$ shopt -u dotglob
kbk@toybox4:~$ echo *
a.txt
kbk@toybox4:~$
kbk@toybox4:~$ GLOBIGNORE=*
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ shopt -s failglob
kbk@toybox4:~$ echo *
-bash: no match: *
kbk@toybox4:~$ shopt -u failglob
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ GLOBIGNORE=
kbk@toybox4:~$ echo *
.bash_history .bash_logout .bashrc .landscape .motd_shown .profile .sudo_as_admin_successful .viminfo .vscode-server a.txt
kbk@toybox4:~$
なんてことになる
(最後の echo *
でドットファイルが出てくるのがちょっと謎だけど
(shopt dotglobが勝手に書き変わっている?))。
だからもしファイルが大量にあるディレクトリに対してやってしまうと それなりに時間がかかることになるんじゃないかなあ (メモリも食うだろうけど)。
じゃあどうするの? というと、globを抑止するためのオプションがあるので これを使った方がいいんじゃないかなあ。
The Set Builtin (Bash Reference Manual)
-f
Disable filename expansion (globbing).
-o option-name
noglob
Same as -f.
kbk@toybox4:~$ ls
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ touch a.txt
kbk@toybox4:~$ echo *
a.txt
kbk@toybox4:~$ set -f
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ set +f
kbk@toybox4:~$ echo *
a.txt
kbk@toybox4:~$ set -o noglob
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ set +o noglob
kbk@toybox4:~$ echo *
a.txt
kbk@toybox4:~$ shopt -s failglob
kbk@toybox4:~$ set -o noglob
kbk@toybox4:~$ echo *
*
kbk@toybox4:~$ set +o noglob
kbk@toybox4:~$ echo *
a.txt
kbk@toybox4:~$ GLOBIGNORE=*
kbk@toybox4:~$ echo *
-bash: no match: *
kbk@toybox4:~$ GLOBIGNORE=
kbk@toybox4:~$ echo *
.bash_history .bash_logout .bashrc .landscape .motd_shown .profile .sudo_as_admin_successful .viminfo .vscode-server a.txt
kbk@toybox4:~$
ただまあ、例の記事のような、関数に渡すときに予想外のglobが行われないように するために使っていいものなのかはよくわからない。
LISP in Space
ちょっと前の新山さんのツイート。
NASA火星探査機にかかわったRon Garretインタビュー。火星は地球から電波が届くのに40分以上かかるので自律走行が不可欠である。彼が研究を始めた1988年当時はPythonもJavaも知られておらず、彼はLISPでロボットを開発した。デバッグ時は実際に火星にS式を送ってREPLを使ったhttps://t.co/4JGFANvkvR
— 新山祐介 (Yusuke Shinyama) (@mootastic) May 3, 2022
1988年当時はPythonもJavaも知られておらず
というのにちょっと引っかかった。
知られていないどころか存在していなかった
(少なくとも世に広く公開されてはいなかった)
んじゃなかろうか?
ということで例によって元記事 (というか元podcastのtranscript)に
LISP in Space With Ron Garret - CoRecursive Podcast
Ron: So you have to keep in mind that there is no Java, there is no Python, there is no JavaScript, there is no C++. There is Pascal and C and basic and machine code, and that’s pretty much it in terms of popular languages. And to get anything done in any of those languages is just really, really hard. And this by contrast gives you all of this high level abstraction that you can just use without having to worry about it. And so you don’t have to worry about memory management, you don’t have to worry about dangling pointers. It’s just so much faster and easier to get things done when the language you’re using provides you with some of these high level abstractions. And in a world where the only language that has that is LISP, knowing LISP really is like a superpower. It just blew everything else out of the water back in those days.
ふむ。
ところでこの回のページから番組のページ All Episodes - CoRecursive Podcast に行って気がついたのだけど
- The Internet Is Made of Duct Tape - CoRecursive Podcast
- Leaving Debian With Joey Hess - CoRecursive Podcast
- Quines, Polyglot Code and Other Fun Computations With Don McKay - CoRecursive Podcast
- The Untold Story of SQLite With Richard Hipp - CoRecursive Podcast
これも以前に新山さんが紹介していたSQLiteの回もあった番組なのね。
from scratch
アセンブラすらも存在しない状態から始めて最終的にGCCまで手作業で到達するというプロジェクト。まずx86アセンブラを16進で入力し、つぎにアセンブラのみで書かれたブートストラップ用の極小Cコンパイラを開発している。すごい執念https://t.co/nz5XNhlXWB
— 新山祐介 (Yusuke Shinyama) (@mootastic) May 3, 2022
一瞬 Mes - GNU Project - Free Software Foundation のことだろうかと思ったのだけど 別のプロジェクトなのね。
oriansj/stage0: A set of minimal dependency bootstrap binaries
Goal
This is a set of manually created hex programs in a Cthulhu Path to madness fashion. Which only have the goal of creating a bootstrapping path to a C compiler capable of compiling GCC, with only the explicit requirement of a single 1 KByte binary or less.
Additionally, all code must be able to be understood by 70% of the population of programmers. If the code can not be understood by that volume, it needs to be altered until it satisfies the above requirement.
新山さんのツイートにあったリンク先はstage2
というディレクトリにあるファイルなんだけど
同じディレクトリにはFORTHとLISPのソースもあった。
- stage0/cc_x86.s at master · oriansj/stage0
- stage0/forth.s at master · oriansj/stage0
- stage0/lisp.s at master · oriansj/stage0
リポジトリの上から見ていくと、ステージは 0から始まって3まであるようだ。
- stage0/stage0 at master · oriansj/stage0
- stage0/stage1 at master · oriansj/stage0
- stage0/stage2 at master · oriansj/stage0
- stage0/stage3 at master · oriansj/stage0
そしてブートストラップの一番最初はここかな?
- stage0/stage0_monitor.hex0 at master · oriansj/stage0
- stage0/stage0_monitor.s at master · oriansj/stage0
洋書のお値段
邦訳の刊行が期待される洋書を紹介しまくることにする(2022年版) - YAMDAS現更新履歴 で再度 Modern Mainframe Development: COBOL, Databases, and Next-Generation Approaches が取り上げられていたけど
オライリー本家からメインフレーム開発本が出る! - YAMDAS現更新履歴
6月に出るらしい洋書の値段がべらぼうでビビるが(恐るべし円安)、邦訳は出ますかねぇ。
日本語版が出るかどうかはともかく、 Amazonでのこの値段(先ほど確認した時点では8752JPY)なのは 元々が高い本だから(同じく(Amazon.comで)69.99USD) ということが大きいような。
新品:¥9,324
参考価格: ¥10,024
値下がりしました: ¥700 (7%)
値段、あがっとりますな。
そう言えば連休中、とある書店で見かけた 買おうかどうしようか悩んだのだけど 結局その場では買わなかったとある本の値段が、 調べてみると書店で買うよりもAmazon(jp)で買う方が(2000円ほど)高くなっててびっくりした。 逆(Amazonで買う方が数千円単位で安くなる)はさんざん見てきたけど これは初体験だったかもしれない。 これも(急激な)円安の影響なんですかねえ…
C23
WG 14 Document log を見ると N2984 2022/05/05 Keaton, Revised C23 Schedule にこれからのスケジュールがあって それはざっとこんな感じ
Start | Event | Days | Completed |
---|---|---|---|
2022-05-16 | Committee meeting (virtual) | 5 | 2022-05-20 |
Deadline for documents (final version of proposals) | 2022-06-17 | ||
2022-07-18 | Committee meeting (virtual) | 5 | 2022-07-22 |
2022-07-25 | Action items complete from meeting | 7 | 2022-08-01 |
2022-08-01 | Editor revises draft | 7 | 2022-08-08 |
2022-08-08 | Editorial review | 7 | 2022-08-15 |
2022-08-15 | Editor readies document for CD | 7 | 2022-08-22 |
2022-08-22 | CD ballot | 91 | 2022-11-21 |
Deadline for documents | 2022-12-09 | ||
2023-01-09 | Ballot resolution/Committee meeting (hybrid?) | 5 | 2023-01-13 |
2023-01-16 | Action items complete from meeting | 7 | 2023-01-23 |
2023-01-23 | Editor revises draft | 7 | 2023-01-30 |
2023-01-30 | Editorial review | 14 | 2023-02-13 |
2023-02-13 | Editor readies document for DIS | 7 | 2023-02-20 |
2023-02-20 | ISO editing (submit DIS ballot) | 56 | 2023-04-17 |
2023-04-17 | DIS ballot | 182 | 2023-10-16 |
2023-10-16 | Contingency | 14 | 2023-10-30 |
2023-10-30 | Editor prepares IS | 14 | 2023-11-13 |
んで直近のMEETING OF ISO/IEC JTC 1/SC 22/WG 14 AND INCITS PL22.11 WG 14/N 2985
のAgendaがこちら。
N 2985: Agenda for May, 2022
Public Money, Public Code
新山さんも取り上げたこの件、ふと 「誰宛」のものなのか気になった (公開状 - Wikipedia)。
Tell Your Representatives!
In our open letter we demand:
“Implement legislation requiring that publicly financed software developed for the public sector be made publicly available under a Free and Open Source Software licence.”
214 organisations and 33087 individuals already support this call for action by signing our open letter. You can help us make a much bigger impact by signing it, too! We will hand over all signatures to representatives all over Europe that are debating software freedom in public administration.
ふむ。 「日本からの署名も可能」 とはあるけど、意味とか効力とか その辺はどうなんだろう?>日本(ヨーロッパ以外)からの署名