このリポジトリは、シェルスクリプトの練習・実験用のリポジトリです。
雑多なスクリプトが入っています。今までに書いたスクリプトを整理してここに移していく予定です。
POSIX シェルで動作することを好みますが、合理的な範囲での努力のみで済ませ、 bash や zsh に依存することもあります。
その場合もなるべく shebang を #!/usr/bin/env bash で書くことにして環境の違いを吸収するようにしています。
また、 BSD 系のコマンドと GNU 系のコマンドの違いも合理的な範囲でのみ考慮することにします。 しかし、互換性のために多すぎる努力をすることは避け、コメントで補うことにします。
可能ならばテストを書くようにします。
This repository is for practicing and experimenting with shell scripts.
It contains various scripts. I will organize the scripts I have written so far and move them here.
I prefer that the scripts work with POSIX shell, but I also depend on bash and zsh within a reasonable range of effort.
In that case, I try to write the shebang as #!/usr/bin/env bash as much as possible to absorb the differences in the environment.
Also, I will only consider the differences between BSD and GNU commands within a reasonable range of effort. However, I will avoid making too much effort for compatibility and supplement it with comments.
If possible, I will write tests.
generate-web-icons は ImageMagick 7 の magick と ImageMagick 6 の convert をサポートします。
magick が存在する場合は優先して使い、 Ubuntu の imagemagick パッケージとこのリポジトリの CI ベースラインが ImageMagick 6 を提供している間は convert のフォールバックを維持します。
generate-web-icons supports ImageMagick 7 through magick and ImageMagick 6 through convert.
It prefers magick when available, and keeps the convert fallback while Ubuntu's imagemagick package and this repository's CI baseline provide ImageMagick 6.
env-run reads .env from the current working directory and rejects oversized input before exporting it:
- Maximum
.envsize: 65,536 bytes (configurable viaENV_RUN_MAX_ENV_BYTES) - Maximum value size per variable: 4,096 bytes (configurable via
ENV_RUN_MAX_VALUE_BYTES)
If either bound is exceeded, env-run exits with an error instead of invoking the target command.
generate-web-icons validates input images before conversion:
- Maximum file size: 50MB (configurable via
GENERATE_WEB_ICONS_MAX_INPUT_BYTES) - Maximum pixel count: 16,777,216 (16 megapixels, configurable via
GENERATE_WEB_ICONS_MAX_INPUT_PIXELS)
If an input image exceeds these bounds, the script exits with a clear error before invoking any conversion.
git clone [email protected]:kitsuyui/shellscript-playground.gitAdd the following to your .bashrc or .zshrc:
export PATH="$PATH:/path/to/shellscript-playground/bin"Install lefthook and then run:
lefthook installThis sets up the following Git hooks:
- pre-commit: runs
./tests/shfmt.sh(format check) and./tests/shellcheck.sh(lint) - pre-push: runs
./tests/shfmt.sh,./tests/shellcheck.sh, and./tests/all.sh(full test suite)
CI runs the full suite (shfmt, shellcheck, and all.sh) on every pull request.
MIT License