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
260
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
70
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
96
あなたの知らないバージョン命名規則
sat
PRO
3
910
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
64
Machine Check Exception
sat
PRO
2
67
バイナリダンプの模様を読む
sat
PRO
0
91
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
90
114-ファイルのshallow_copy.pdf
sat
PRO
2
58
113-Btrfsのスナップショット.pdf
sat
PRO
0
41
Other Decks in Technology
See All in Technology
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
110
絵ではじめるKubernetesセキュリティ
aoi1
5
710
AI Agent入門〜今更聞けないAgentの話〜
hiromimaganuma
0
120
Deployment の 先にある AI Agent 基盤 - kagent vNext、Agent Substrate、Hermes から読み解く Agent Runtime の現在地 / k8s-matsuri-2-ai-agent-platform-amsy810
masayaaoyama
5
740
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
12
7.2k
高負荷プロダクション環境におけるAWS Lambdaのリアル 〜スケールとコストを左右する実行ライフサイクルの技術仕様〜
maimyyym
2
590
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
290
AIエージェントを安全で速い現場監督にする:Jev・Obsidian・メタハーネス
x5gtrn
PRO
0
110
リアーキテクチャ後の障害ゼロを目指したShadow Testingの取り組み
nihonbuson
PRO
1
180
手を動かして実感する、Kiro が変える開発体験
inariku
0
320
AIエージェントを最高のパートナーに育てる方法|評価と判断軸を育てる5つのステップ
koichiaoki
1
160
Kiro Meetup #8 Kiro アップデート (2026/3/21〜2026/9/24)
katzueno
1
220
Featured
See All Featured
Design in an AI World
tapps
1
330
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Making the Leap to Tech Lead
cromwellryan
135
10k
Producing Creativity
orderedlist
PRO
348
41k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
Deep Space Network (abreviated)
tonyrice
0
320
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Writing Fast Ruby
sferik
630
63k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Code Review Best Practice
trishagee
74
20k
Everyday Curiosity
cassininazir
0
330
Speed Design
sergeychernyshev
33
2.1k
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には組み込みコマンドが存在する • 組み込みコマンドにする目的はさまざま ◦ 高速化 ◦ そもそも実行ファイルでは実現できない