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
ポーリングと割り込み
sat
PRO
0
14
Rook: Intro and Deep Dive With Ceph
sat
PRO
1
110
会社員しながら本を書いてきた知見の共有
sat
PRO
3
790
デバイスにアクセスするデバイスファイル
sat
PRO
1
39
ファイルシステムのデータを ブロックデバイスへの操作で変更
sat
PRO
1
34
デバイスドライバ
sat
PRO
0
49
マルチスレッドの実現方法 ~カーネルスレッドとユーザスレッド~
sat
PRO
2
130
共有メモリ
sat
PRO
3
71
マルチスレッドプログラム
sat
PRO
3
59
Other Decks in Technology
See All in Technology
cdk initで生成されるあのファイル達は何なのか/cdk-init-generated-files
tomoki10
1
670
[SRE NEXT] ARR150億円_エンジニア140名_27チーム_17プロダクトから始めるSLO.pdf
satos
5
3k
microCMSではじめるAIライティング
himaratsu
0
150
LIXIL基幹システム刷新に立ち向かう技術的アプローチについて
tsukuha
1
380
SREの次のキャリアの道しるべ 〜SREがマネジメントレイヤーに挑戦して、 気づいたこととTips〜
coconala_engineer
1
4.3k
CDK Vibe Coding Fes
tomoki10
1
630
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
820
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
18k
AI Ready API ─ AI時代に求められるAPI設計とは?/ AI-Ready API - Designing MCP and APIs in the AI Era
yokawasa
6
1.9k
対話型音声AIアプリケーションの信頼性向上の取り組み
ivry_presentationmaterials
3
1k
Amplify Gen2から知るAWS CDK Toolkit Libraryの使い方/How to use the AWS CDK Toolkit Library as known from Amplify Gen2
fossamagna
1
350
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
YesSQL, Process and Tooling at Scale
rocio
173
14k
A Modern Web Designer's Workflow
chriscoyier
695
190k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.3k
Agile that works and the tools we love
rasmusluckow
329
21k
Writing Fast Ruby
sferik
628
62k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Practical Orchestrator
shlominoach
189
11k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
Six Lessons from altMBA
skipperchong
28
3.9k
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/