Skip to content

Instantly share code, notes, and snippets.

@Amakata
Created March 23, 2017 13:53
Show Gist options
  • Save Amakata/5e3f01306d2692468d54e4e9a7805b61 to your computer and use it in GitHub Desktop.
Save Amakata/5e3f01306d2692468d54e4e9a7805b61 to your computer and use it in GitHub Desktop.
shのお勉強
#!/bin/sh
# コマンドでエラーが返ってきた時点で停止
set -e
# 1つめの引数に-が含まれている場合 ${variable#pattern}で、variableの値の最初の部分とpatternが一致した場合に、最も短く一致した部分を削除して、残りを返す。
if [ "${1#-}" != "$1" ]; then
# set -- a b は、 --の後のパラメータを$1,$2,...に格納し直す
# "$@"は、$1 $2 $3 ... を "$1" "$2" "$3" という感じの形式に変換する
set -- php "$@"
fi
exec "$@"
@Amakata
Copy link
Author

Amakata commented Mar 23, 2017

${variable#pattern}は、bashのパターンとパターン照合、パターン照合演算子等のキーワードで調べられる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment