LoginSignup
1
2

More than 3 years have passed since last update.

ShellScript で例外処理を実装

Posted at

ShellScript で例外処理 を実装する機会があったのでまとめます。

「||」 OR制御演算子を使って例外処理を実装

#!/bin/bash

function try() {
    //実行する
    php ./test.php
    return 1
}

function error() {
    # エラーの際に実行する。
    php ./errorhandle.php
    exit 1
}

try || error

ShellScriptを実行

sh ファイル名.sh

以上

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2