タグ

関連タグで絞り込む (2)

タグの絞り込みを解除

ShellScriptとbashに関するefclのブックマーク (5)

  • Shell Script Best Practices — The Sharat's

    This article is about a few quick thumb rules I use when writing shell scripts that I’ve come to appreciate over the years. Very opinionated. Things¶ Use bash. Using zsh or fish or any other, will make it hard for others to understand / collaborate. Among all shells, bash strikes a good balance between portability and DX. Just make the first line be #!/usr/bin/env bash, even if you don’t give exec

    efcl
    efcl 2022/10/29
    Bashで書くシェルスクリプトのテンプレート。 set -o 系のテンプレート
  • Why Create a New Unix Shell? (2021)

    Introduction Before explaining why I created Oil, let's review what it is. You can think of a Unix shell in two ways: As a text-based user interface. You communicate with the operating system by typing commands. As a language. It has variables, functions, and loops. Shell programs are text files that start with #!/bin/sh. In this document, we'll think of Unix shells as languages. The Oil project a

    efcl
    efcl 2021/09/16
    シェルスクリプトをよりまともな言語として扱えるようにするためにoilというシェルを作っているという話
  • Minimal safe Bash script template

    Published on December 14, 2020   ·   Updated on December 16, 2020 Bash scripts. Almost anyone needs to write one sooner or later. Almost no one says “yeah, I love writing them”. And that’s why almost everyone is putting low attention while writing them. I won’t try to make you a Bash expert (since I’m not a one either), but I will show you a minimal template that will make your scripts safer. You

    Minimal safe Bash script template
    efcl
    efcl 2021/01/17
    Bashスクリプトのテンプレート。 引数パース、色、trap、終了コード
  • Bashのテストツールをつくった - 技術野郎の復習

    Bash, Shellscript, Testing Framework, Linux, ShellTL;DRtoromoti/chocomint.sh(github)数カ月前に超絶便利なBashのテストツール*1をリリースした。ジャンル的にはsstephenson/bats(github)やmpapis/tf(github)と同じようなもの。乱暴に言えば、この2つを掛け合わせたようなツール。動機Bashで書いたコマンドラインツールのテストのためになにかいいものはないかとツールを探したが、好みのものが見つからなかったから。使用感わざわざRubyなんてインストールしたくないし、もっと言えば実際に動くスクリプトのなかのコメント文にテストを書きたいというズボラな僕のためのツール。たとえば、あまり例としては良くないんですが、こういうスクリプトがあるとしたら #!/usr/bin/env choco

    efcl
    efcl 2014/11/09
    コメントを書いてテストするDoctest的な感じ
  • test と [ と [[ コマンドの違い - 拡張 POSIX シェルスクリプト Advent Calendar 2013 - ダメ出し Blog

    test と [ と [[ コマンドの違い - 拡張 POSIX シェルスクリプト Advent Calendar 2013 - ダメ出し Blog 拡張 POSIX シェルスクリプト Advent Calendar 2013、15日目の記事です。 書くのが遅れ、ネタは尽きかけ、 マニアックさやニッチさが足りなくなってきているような気がします。 ふつうの内容ですみません。 今日は test, [, [[ コマンドの違いについてざっくり紹介します。 [[ がある bash, ksh, zsh ならば test と [ の使用は避け、 [[ を使用すべきです。 [ は慎重に使わないと様々な罠にかかるため危険です。 (翌日のネタも併わせてどうぞ) test と [ の違い どちらもシェルの組込みコマンドです。名前が違うのと [ は最後の引数を ] にしなければいけない縛りがある以外、 動作まった

    efcl
    efcl 2013/12/17
    test, [, [[ コマンドの違いについて
  • 1