Created
December 29, 2016 03:32
-
-
Save ryuheechul/4a491431502634fe4e78dbf84ebdab5e to your computer and use it in GitHub Desktop.
Run command with removing newlines in values of ENV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ## strip newlines of envs | |
| # used some code from http://stackoverflow.com/a/11746174 | |
| string=`printenv` | |
| arr=() | |
| while read -r line; do | |
| arr+=("$line") | |
| if [ -n "$line" ]; then | |
| declare $line | |
| #export env with no newline | |
| fi | |
| done <<< "$string" | |
| #run command following after env-strip.sh | |
| $@ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made this script to workaround the issue with Kubernetes.
you can use this script to run your command like this below
$ your/script/location/env-strip.sh rails -sinstead of
$ rails -s