feat: Add document for 'Why Learn Shell Script'#9
Draft
tomoya-sforzando wants to merge 1 commit into
Draft
Conversation
shin-sforzando
requested changes
Sep 10, 2020
shin-sforzando
left a comment
Contributor
There was a problem hiding this comment.
Draftだけど、Reviewerにアサインされてるだけで「未レビューです」の通知が鬱陶しいので、いったんレビューします。
| print(sys.version) | ||
| ``` | ||
|
|
||
| → pythonはインタプリタ型言語なので、シバンが書かれていることによって、ファイル実行できる |
Contributor
There was a problem hiding this comment.
Python。
pythonは英語でニシキヘビのことです。実在する言葉だから、わざわざPを大文字にしてるんです。
|
|
||
| --- | ||
|
|
||
| ## おまけ |
Contributor
There was a problem hiding this comment.
「おまけ」じゃないですよね。Shebangは重要な1項目です。
|
|
||
| - env コマンド - set environment and **execute** command, or print environment | ||
| - → `PATH=` に記載されていることでパスが通っている | ||
| - e.g. `/usr/bin` がある - `$ env | rg /usr/bin` |
Contributor
There was a problem hiding this comment.
Suggested change
| - e.g. `/usr/bin` がある - `$ env | rg /usr/bin` | |
| - e.g. `echo $PATH` |
| - → `PATH=` に記載されていることでパスが通っている | ||
| - e.g. `/usr/bin` がある - `$ env | rg /usr/bin` | ||
| - → パスが通っている = プログラム名だけで実行できる | ||
| - e.g. `/usr/bin` の中には `python` がある - `$ ls /usr/bin | rg python` |
Contributor
There was a problem hiding this comment.
Suggested change
| - e.g. `/usr/bin` の中には `python` がある - `$ ls /usr/bin | rg python` | |
| - e.g. `type python` |
| ## なぜShell Scriptか | ||
|
|
||
| - CLIでの作業を保存、実行 → 自動化 | ||
| - OSごとの実行環境を作らずとも、実行できる |
Contributor
There was a problem hiding this comment.
この利点だとPythonでも良いことになりますよね。
Pythonでも自動化はできるし、OSごとに書き分けたりしません。
Pythonのインストールが必要ですが、それを言ったらsh以外のシェルはたまたま多くの環境に入ってるだけで、
Pythonも多くの環境に標準インストールされてる今、あまり有意な利点とは言えません。
俺が思うに、シェルスクリプト が活きるのはシステムコール(ハードウェア操作、ファイル操作、OSの設定など低レイヤーへの命令)が多い場面です。
Pythonでもファイルの移動できますけど、シェルスクリプトの方がもっと簡単ですよね。
逆にシェルスクリプトの欠点について触れてないのも片手落ちだと思います。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the PR
To close #4 .
Detail of the change
Add
WhyLearnShellScript.md.Exported PDF with Marp (on Extension of Visual Studio Code).
Anticipated impacts
None.
Additional context
None.