Skip to content

Instantly share code, notes, and snippets.

@ryuheechul
Created December 29, 2016 03:32
Show Gist options
  • Select an option

  • Save ryuheechul/4a491431502634fe4e78dbf84ebdab5e to your computer and use it in GitHub Desktop.

Select an option

Save ryuheechul/4a491431502634fe4e78dbf84ebdab5e to your computer and use it in GitHub Desktop.
Run command with removing newlines in values of ENV
#!/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
$@
@ryuheechul

Copy link
Copy Markdown
Author

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 -s
instead of
$ rails -s

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