Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing environment value "TARGET_BUCKET_URL" #16

Merged
merged 1 commit into from
Apr 22, 2019

Conversation

skomma
Copy link
Member

@skomma skomma commented Apr 22, 2019

元の if だと、環境変数が設定されていない、空白文字のときに if の中に入らず、 hoge という文字が出ない。(=想定外の挙動)

bash-4.4# export TARGET_BUCKET_URL=
bash-4.4# if [ ! `echo $TARGET_BUCKET_URL | cut -f1 -d":"` == "gs" ]; then echo 'hoge'; fi
bash-4.4# export TARGET_BUCKET_URL=hoge:
bash-4.4# if [ ! `echo $TARGET_BUCKET_URL | cut -f1 -d":"` == "gs" ]; then echo 'hoge'; fi
hoge
bash-4.4# export TARGET_BUCKET_URL=gs:
bash-4.4# if [ ! `echo $TARGET_BUCKET_URL | cut -f1 -d":"` == "gs" ]; then echo 'hoge'; fi
bash-4.4# unset TARGET_BUCKET_URL
bash-4.4# if [ ! `echo $TARGET_BUCKET_URL | cut -f1 -d":"` == "gs" ]; then echo 'hoge'; fi

修正後の if は、想定通りの挙動になる。

bash-4.4# export TARGET_BUCKET_URL=
bash-4.4# if [ "`echo $TARGET_BUCKET_URL | cut -f1 -d':'`" != "gs" ]; then echo 'hoge'; fi
hoge
bash-4.4# export TARGET_BUCKET_URL=hoge:
bash-4.4# if [ "`echo $TARGET_BUCKET_URL | cut -f1 -d':'`" != "gs" ]; then echo 'hoge'; fi
hoge
bash-4.4# export TARGET_BUCKET_URL=gs:
bash-4.4# if [ "`echo $TARGET_BUCKET_URL | cut -f1 -d':'`" != "gs" ]; then echo 'hoge'; fi
bash-4.4# unset TARGET_BUCKET_URL
bash-4.4# if [ "`echo $TARGET_BUCKET_URL | cut -f1 -d':'`" != "gs" ]; then echo 'hoge'; fi
hoge

@ryu-sato ryu-sato merged commit 8b82c19 into master Apr 22, 2019
@ryu-sato ryu-sato deleted the fix/parse-env-value branch April 22, 2019 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants