Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
bashの組み込みコマンド
Search
Satoru Takeuchi
PRO
June 24, 2022
Technology
270
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
bashの組み込みコマンド
以下動画のテキストです
https://youtu.be/6oVvcnwRUa0
Satoru Takeuchi
PRO
June 24, 2022
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
79
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
110
あなたの知らないバージョン命名規則
sat
PRO
3
920
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
74
Machine Check Exception
sat
PRO
2
71
バイナリダンプの模様を読む
sat
PRO
0
110
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
110
114-ファイルのshallow_copy.pdf
sat
PRO
2
62
113-Btrfsのスナップショット.pdf
sat
PRO
0
46
Other Decks in Technology
See All in Technology
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
280
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
920
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
120
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
120
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
Refining Active Record
shugo
0
150
Kiro Crewをはじめよう
kizawa2020
1
160
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.3k
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
750
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
140
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
320
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
Navigating Team Friction
lara
192
16k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Exploring anti-patterns in Rails
aemeredith
4
540
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
Transcript
bashの組み込みコマンド Jun. 24th, 2022 Satoru Takeuchi twitter: satoru_takeuchi
bashの組み込みコマンドとは • bash上で”help”を実行すると出てくるコマンドたち • 新規プロセスを生成せずにbash自身が処理 • 種類 ◦ “if”や”for”などの制御構文 ◦
echoなどの頻出コマンド ◦ waitやcdなどの組み込みコマンドでなければ実現できないもの
echoはなぜ組み込みコマンドなのか • bashスクリプト内で頻出するので高速なほうが都合がよい ◦ /bin/echoを実行するとbashを親とした新規プロセスの生成が必要 ◦ 組み込みコマンドなら新規プロセスの生成が不要 • 実験: 組み込みコマンド(echo)
vs 実行ファイル(/bin/echo) ◦ bashスクリプト内で10000回実行したときの所要時間を比較 • 📝 実はtimeも組み込みコマンド ◦ しかも組み込みコマンドと実行ファイルで微妙にデフォルト出力が違う
waitはなぜ組み込みコマンドなのか • “wait”は子プロセスの終了を親が待つシステムコール ◦ 子ではないプロセスの終了は待てない • “man 2 wait”より抜粋 ◦
All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has changed.
cdはなぜ組み込みコマンドなのか • “cd”は内部的に”chdir”システムコールを呼ぶ • “chdir”はシステムコールを呼んだプロセスのワーキングディレクトリを変更 • “man 2 chdir”より抜粋 ◦
chdir() changes the current working directory of the calling process to the directory specified in path. • 親プロセス(bash)には影響を及ぼさない
まとめ • bashには組み込みコマンドが存在する • 組み込みコマンドにする目的はさまざま ◦ 高速化 ◦ そもそも実行ファイルでは実現できない