Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
bashの組み込みコマンドの自作
Search
Satoru Takeuchi
PRO
June 24, 2022
Technology
0
140
bashの組み込みコマンドの自作
以下動画のテキストです
https://youtu.be/wXgkrMsxYqk
Satoru Takeuchi
PRO
June 24, 2022
Tweet
Share
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
Rook: Intro and Deep Dive With Ceph
sat
PRO
1
110
会社員しながら本を書いてきた知見の共有
sat
PRO
3
790
デバイスにアクセスするデバイスファイル
sat
PRO
1
38
ファイルシステムのデータを ブロックデバイスへの操作で変更
sat
PRO
1
32
デバイスドライバ
sat
PRO
0
49
マルチスレッドの実現方法 ~カーネルスレッドとユーザスレッド~
sat
PRO
2
120
共有メモリ
sat
PRO
3
71
マルチスレッドプログラム
sat
PRO
3
59
Linuxのブートプロセス initramfs編
sat
PRO
2
88
Other Decks in Technology
See All in Technology
What’s new in Android development tools
yanzm
0
310
Model Mondays S2E04: AI Developer Experiences
nitya
0
140
american airlines®️ USA Contact Numbers: Complete 2025 Support Guide
supportflight
1
110
LLM時代の検索
shibuiwilliam
2
160
United airlines®️ USA Contact Numbers: Complete 2025 Support Guide
unitedflyhelp
0
310
Tokyo_reInforce_2025_recap_iam_access_analyzer
hiashisan
0
190
開発生産性を組織全体の「生産性」へ! 部門間連携の壁を越える実践的ステップ
sudo5in5k
2
7.2k
KubeCon + CloudNativeCon Japan 2025 Recap Opening & Choose Your Own Adventureシリーズまとめ
mmmatsuda
0
280
american aa airlines®️ USA Contact Numbers: Complete 2025 Support Guide
aaguide
0
150
B2C&B2B&社内向けサービスを抱える開発組織におけるサービス価値を最大化するイニシアチブ管理
belongadmin
1
7k
Yahoo!しごとカタログ 新しい境地を創るエンジニア募集!
lycorptech_jp
PRO
0
110
KubeCon + CloudNativeCon Japan 2025 Recap
ren510dev
1
380
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Statistics for Hackers
jakevdp
799
220k
4 Signs Your Business is Dying
shpigford
184
22k
Why Our Code Smells
bkeepers
PRO
336
57k
How STYLIGHT went responsive
nonsquared
100
5.6k
Done Done
chrislema
184
16k
KATA
mclloyd
30
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Designing Experiences People Love
moore
142
24k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Transcript
bashの組み込みコマンドを自作 Jun. 24th, 2022 Satoru Takeuchi twitter: satoru_takeuchi
おさらい: bashの組み込みコマンドとは • 📝 過去動画: bashの組み込みコマンドより抜粋 ◦ https://youtu.be/6oVvcnwRUa0 • bash上で”help”を実行すると出てくるコマンドたち
• 新規プロセスを生成せずにbash自身が処理
bashの組み込みコマンドは自作できる • 必要なパッケージ(Ubuntu 20.04を想定) ◦ bash-builtins • 開発言語 ◦ C言語
helloと出力する組み込みコマンドを作る • ソースの場所 ◦ https://github.com/satoru-takeuchi/youtube-sample/tree/master/0042-create-bash-builtin-commands • ビルド方法 ◦ make •
組み込み方法 ◦ enable -f ./myhello.so myhello • 実行ファイル形式のコマンドとの性能比較 ◦ ./bench.sh
組み込みコマンド自作機能についての私見 • 面白いけど、あまり使う場面はなさそう • 性能向上するケースが限られる ◦ コマンド実行コストのほとんどがプロセスの生成コスト ◦ コマンドが大量に呼ばれる •
C言語のソースを書いてメンテするのが面倒 • 使う前にいちいち組み込むのが面倒
まとめ • bashの組み込みコマンドは自作できる • 面白いが使い道は限られる • 📝 興味ある方はbash-builtinsのドキュメントを参照 ◦ /usr/share/doc/bash-builtins/examples/