目次
導入
参考:
使い方
参考:
Bash のシェルスクリプトの記述に関してメモ等 – Qiita
サブシェル
参考:
Command Grouping | Bash Reference Manual
スクリプトのパスを取得する
実行中のスクリプトファイルが存在するディレクトリの絶対パスを取得する。
SCRIPT_DIR=$(cd $(dirname $0); pwd)
Code language: Bash (bash)
参考:
スクリプトのおかれているディレクトリの完全なパスを取得したい – Qiita
Determine the path of the executing BASH script – Stack Overflow
Quoting within $(command substitution) in Bash – Unix & Linux Stack Exchange
ファイルからデータを読み出して処理する
参考:
Pass stdin as argument to bash script – Unix & Linux Stack Exchange
LINENO / BASH_LINENO
参考:
実行中のスクリプトの現在の行番号を調べる | あんみのの備忘録
シェルのスクリプトで現在の実行行の取得/行番号の取得 – Qiita
エラー処理
参考:
Debug Bash Scripts with Line Numbers & more info | Coderwall
Bash error reporting | David Winterbottom
Getting the line number of a shell script error – Stack Overflow
How do I find the line number in Bash when an error occured? – Unix & Linux Stack Exchange
まとめ/チートシート
参考:
Bash Scripting Cheatsheet | Devhints
ShellCheck
シェルスクリプトの文法や潜在的なバグをチェックする。
ツール:
ShellCheck – Shell Script Analysis Tool [Official]
リポジトリ:
koalaman/shellcheck: ShellCheck, a static analysis tool for shell scripts – GitHub
参考: