642 lines
23 KiB
HTML
642 lines
23 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html lang="" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>shell · hello world! bluesky</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="description" content="">
|
|
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
|
<meta name="author" content="syui">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/style.css">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="HandheldFriendly" content="true"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
|
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
|
|
|
|
|
<link rel="next" href="4.html" />
|
|
|
|
|
|
<link rel="prev" href="2.html" />
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="book">
|
|
<div class="book-summary">
|
|
|
|
|
|
<div id="book-search-input" role="search">
|
|
<input type="text" placeholder="Type to search" />
|
|
</div>
|
|
|
|
|
|
<nav role="navigation">
|
|
|
|
|
|
|
|
<ul class="summary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="chapter " data-level="1.1" data-path="../">
|
|
|
|
<a href="../">
|
|
|
|
|
|
hello world! bluesky
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.2" data-path="../card/">
|
|
|
|
<a href="../card/">
|
|
|
|
|
|
card
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3" data-path="../c1/">
|
|
|
|
<a href="../c1/">
|
|
|
|
|
|
part 1
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.3.1" data-path="../c1/1.html">
|
|
|
|
<a href="../c1/1.html">
|
|
|
|
|
|
quick start
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3.2" data-path="../c1/2.html">
|
|
|
|
<a href="../c1/2.html">
|
|
|
|
|
|
example
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4" data-path="./">
|
|
|
|
<a href="./">
|
|
|
|
|
|
part 2
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.4.1" data-path="1.html">
|
|
|
|
<a href="1.html">
|
|
|
|
|
|
bluesky
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4.2" data-path="2.html">
|
|
|
|
<a href="2.html">
|
|
|
|
|
|
terminal
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter active" data-level="1.4.3" data-path="3.html">
|
|
|
|
<a href="3.html">
|
|
|
|
|
|
shell
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4.4" data-path="4.html">
|
|
|
|
<a href="4.html">
|
|
|
|
|
|
rust
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5" data-path="../c3/">
|
|
|
|
<a href="../c3/">
|
|
|
|
|
|
part 3
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.5.1" data-path="../c3/1.html">
|
|
|
|
<a href="../c3/1.html">
|
|
|
|
|
|
hello world
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5.2" data-path="../c3/2.html">
|
|
|
|
<a href="../c3/2.html">
|
|
|
|
|
|
seahorse
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5.3" data-path="../c3/3.html">
|
|
|
|
<a href="../c3/3.html">
|
|
|
|
|
|
reqwest
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.6" data-path="../c4/">
|
|
|
|
<a href="../c4/">
|
|
|
|
|
|
part 4
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.6.1" data-path="../c4/0.html">
|
|
|
|
<a href="../c4/0.html">
|
|
|
|
|
|
ai
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.6.2" data-path="../c4/1.html">
|
|
|
|
<a href="../c4/1.html">
|
|
|
|
|
|
config
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.6.3" data-path="../c4/2.html">
|
|
|
|
<a href="../c4/2.html">
|
|
|
|
|
|
mention
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.6.4" data-path="../c4/3.html">
|
|
|
|
<a href="../c4/3.html">
|
|
|
|
|
|
base64
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.7" data-path="../c5/">
|
|
|
|
<a href="../c5/">
|
|
|
|
|
|
part 5
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.7.1" data-path="../c5/1.html">
|
|
|
|
<a href="../c5/1.html">
|
|
|
|
|
|
notify
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.7.2" data-path="../c5/2.html">
|
|
|
|
<a href="../c5/2.html">
|
|
|
|
|
|
timeline
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.7.3" data-path="../c5/3.html">
|
|
|
|
<a href="../c5/3.html">
|
|
|
|
|
|
refresh
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.8" data-path="../end/">
|
|
|
|
<a href="../end/">
|
|
|
|
|
|
end
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="book-body">
|
|
|
|
<div class="body-inner">
|
|
|
|
|
|
|
|
<div class="book-header" role="navigation">
|
|
|
|
|
|
<!-- Title -->
|
|
<h1>
|
|
<i class="fa fa-circle-o-notch fa-spin"></i>
|
|
<a href=".." >shell</a>
|
|
</h1>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="page-wrapper" tabindex="-1" role="main">
|
|
<div class="page-inner">
|
|
|
|
<div id="book-search-results">
|
|
<div class="search-noresults">
|
|
|
|
<section class="normal markdown-section">
|
|
|
|
<h3 id="shell">shell</h3>
|
|
<p>パッケージ・マネージャーが導入できたと思うので、まずは<code>curl</code>をインストールしてみてください。</p>
|
|
<pre><code class="lang-sh"><span class="hljs-comment"># windows</span>
|
|
scoop install curl
|
|
|
|
<span class="hljs-comment"># mac</span>
|
|
brew install curl
|
|
|
|
<span class="hljs-comment"># linux(ubuntu)</span>
|
|
sudo apt install curl
|
|
</code></pre>
|
|
<p>そして、terminalで以下のコマンドを実行してください。</p>
|
|
<pre><code class="lang-sh">curl https://bsky.social/xrpc/_health
|
|
</code></pre>
|
|
<p>結果は、以下の通り。bluesky(bsky.social)のpdsのversionが返ってくるはずです。</p>
|
|
<div><p class="code-filename">output</p></div>
|
|
<pre><code class="lang-sh">{<span class="hljs-string">"version"</span>:<span class="hljs-string">"b2ef3865bc143bfe4eef4a46dbd6a44053fa270d"</span>}
|
|
</code></pre>
|
|
<p>なお、<code>curl</code>がうまく動作しない場合、インストールされたbinaryにpath(パス)が通っていない事が考えられます。</p>
|
|
<p>これも主にwindowsで発生しやすいと思われます。</p>
|
|
<p>ここで、pathについて少し解説します。</p>
|
|
<h4 id="path">path</h4>
|
|
<p>terminalを起動すると、そこではshellと呼ばれるプログラムが待機されています。</p>
|
|
<p>ユーザーはこのshellを通してコマンドを実行することになります。</p>
|
|
<p>shellにも色々なshellがあります。</p>
|
|
<p>例えば、windowsにはmicrosoftの<code>cmd</code>, <code>pwsh</code>というshellがあります。</p>
|
|
<p>unix(mac), linux(ubuntu)の場合は<code>bash</code>, <code>zsh</code>などがあります。</p>
|
|
<p>shellはコマンドを実行する際、<code>PATH</code>に追加されているディレクトリを省略することができます。</p>
|
|
<p>例えば、<code>curl</code>が<code>/usr/bin/curl</code>にインストールされたとしましょう。この場合は、shellは以下のコマンドを実行しなければなりません。</p>
|
|
<pre><code class="lang-sh">/usr/bin/curl --help
|
|
</code></pre>
|
|
<p>しかし、<code>PATH</code>に<code>/usr/bin</code>が追加されている場合、ディレクトリの記述を省略することができます。</p>
|
|
<pre><code class="lang-sh">curl --help
|
|
</code></pre>
|
|
<p>プログラム本体(binary)がどこにあるのか探す場合は、以下のようなコマンドを使います。</p>
|
|
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> curl
|
|
</code></pre>
|
|
<p>ただし、pathが通っていないと使えません。</p>
|
|
<p>pathを通すには、環境変数に当該ディレクトリを記述します。</p>
|
|
<pre><code class="lang-sh">PATH=<span class="hljs-variable">$PATH</span>:/usr/bin
|
|
</code></pre>
|
|
<p>なお、ディレクトリ(directory)は<code>dir</code>や<code>フォルダ</code>と呼ばれることがあります。</p>
|
|
<h4 id="記法の">記法の"$"</h4>
|
|
<p>次に、shellの記述方式に関する注意点を書きます。</p>
|
|
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> curl
|
|
</code></pre>
|
|
<pre><code class="lang-sh">$ <span class="hljs-built_in">which</span> curl
|
|
</code></pre>
|
|
<p>これらは同じ意味を持ちます。</p>
|
|
<p>もし文章でshellの実行を説明する場合、先頭に<code>$</code>を記述する慣習があります。</p>
|
|
<p>この<code>$</code>は「shellで実行します」という意味です。</p>
|
|
<p>例えば、コマンドの実行結果と一緒に載せたい場合、下記のようになります。</p>
|
|
<pre><code class="lang-sh">$ <span class="hljs-built_in">which</span> curl
|
|
/usr/bin/curl
|
|
</code></pre>
|
|
<p>このようにコマンドと実行結果を一緒に載せたい場合がよくあり、もし<code>$</code>がないと、どちらがコマンドで、どちらが実行結果かが分かりづらくなるからです。</p>
|
|
<p>本書では、コピーの弊害などを考慮して、<code>$</code>をなるべく省略しています。</p>
|
|
<p>しかし、本来であれば、全てのコードレイアウトにshellで実行する場合は<code>$</code>を記述すべきと考えられています。</p>
|
|
<h4 id="shebang">shebang</h4>
|
|
<p>次に、shell script(シェル・スクリプト)やshebang(シバン)について解説します。</p>
|
|
<p>この辺はshellによって違いがありますが、<code>bash</code>を前提に話をします。</p>
|
|
<p>テキストファイルに以下を記述して、実行権限を与えて実行してください。</p>
|
|
<div><p class="code-filename">test.sh</p></div>
|
|
<pre><code class="lang-sh"><span class="hljs-meta">#!/bin/bash</span>
|
|
curl https://bsky.social/xrpc/_health
|
|
</code></pre>
|
|
<p>実行権限の付与、及び実行は以下のコマンドです。</p>
|
|
<pre><code class="lang-sh">chmod +x test.sh
|
|
./test.sh
|
|
</code></pre>
|
|
<p>するとbsky.socialのversionが出力されます。</p>
|
|
<pre><code class="lang-sh">{<span class="hljs-string">"version"</span>:<span class="hljs-string">"b2ef3865bc143bfe4eef4a46dbd6a44053fa270d"</span>}
|
|
</code></pre>
|
|
<p>テキストファイルの最初の行<code>#!/bin/bash</code>がシバンと呼ばれるものです。</p>
|
|
<p>ここで、テキストファイルをどのプログラム言語で実行するのかが指定されます。</p>
|
|
<p>次はプログラム言語の簡単な解説を行います。</p>
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
<div class="search-results">
|
|
<div class="has-results">
|
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
|
|
</div>
|
|
<div class="no-results">
|
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a href="2.html" class="navigation navigation-prev " aria-label="Previous page: terminal">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
|
|
<a href="4.html" class="navigation navigation-next " aria-label="Next page: rust">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"shell","level":"1.4.3","depth":2,"next":{"title":"rust","level":"1.4.4","depth":2,"path":"c2/4.md","ref":"c2/4.md","articles":[]},"previous":{"title":"terminal","level":"1.4.2","depth":2,"path":"c2/2.md","ref":"c2/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/3.md","mtime":"2023-07-21T09:07:50.025Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-09-16T08:55:27.618Z"},"basePath":"..","book":{"language":""}});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook.js"></script>
|
|
<script src="../gitbook/theme.js"></script>
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
|
|
|
</body>
|
|
</html>
|
|
|