Skip to content

feat: Add document for 'Why Learn Shell Script'#9

Draft
tomoya-sforzando wants to merge 1 commit into
mainfrom
004_why_learn_shell_script
Draft

feat: Add document for 'Why Learn Shell Script'#9
tomoya-sforzando wants to merge 1 commit into
mainfrom
004_why_learn_shell_script

Conversation

@tomoya-sforzando

Copy link
Copy Markdown
Contributor

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.

@tomoya-sforzando tomoya-sforzando added the documentation Improvements or additions to documentation label Aug 10, 2020
@tomoya-sforzando tomoya-sforzando self-assigned this Aug 10, 2020

@shin-sforzando shin-sforzando left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draftだけど、Reviewerにアサインされてるだけで「未レビューです」の通知が鬱陶しいので、いったんレビューします。

print(sys.version)
```

→ pythonはインタプリタ型言語なので、シバンが書かれていることによって、ファイル実行できる

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python。
pythonは英語でニシキヘビのことです。実在する言葉だから、わざわざPを大文字にしてるんです。


---

## おまけ

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「おまけ」じゃないですよね。Shebangは重要な1項目です。


- env コマンド - set environment and **execute** command, or print environment
- → `PATH=` に記載されていることでパスが通っている
- e.g. `/usr/bin` がある - `$ env | rg /usr/bin`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- e.g. `/usr/bin` の中には `python` がある - `$ ls /usr/bin | rg python`
- e.g. `type python`

## なぜShell Scriptか

- CLIでの作業を保存、実行 → 自動化
- OSごとの実行環境を作らずとも、実行できる

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この利点だとPythonでも良いことになりますよね。
Pythonでも自動化はできるし、OSごとに書き分けたりしません。
Pythonのインストールが必要ですが、それを言ったらsh以外のシェルはたまたま多くの環境に入ってるだけで、
Pythonも多くの環境に標準インストールされてる今、あまり有意な利点とは言えません。

俺が思うに、シェルスクリプト が活きるのはシステムコール(ハードウェア操作、ファイル操作、OSの設定など低レイヤーへの命令)が多い場面です。
Pythonでもファイルの移動できますけど、シェルスクリプトの方がもっと簡単ですよね。

逆にシェルスクリプトの欠点について触れてないのも片手落ちだと思います。

@shin-sforzando shin-sforzando changed the title Add document for 'Why learn Shell Script' feat: Add document for 'Why Learn Shell Script' Feb 21, 2021
Base automatically changed from master to main February 21, 2021 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why learn Shell Script

2 participants