Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Created October 24, 2019 12:45
Show Gist options
  • Select an option

  • Save CreatiCoding/2fc68094be47ccb4d504190381311aa3 to your computer and use it in GitHub Desktop.

Select an option

Save CreatiCoding/2fc68094be47ccb4d504190381311aa3 to your computer and use it in GitHub Desktop.
shell script programming
#!/bin/bash
uname_out="$(uname -s)"
case "${uname_out}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${uname_out}"
esac
flag=0
if [ "$1" = "development" ]; then flag=1; fi
if [ "$1" = "testing" ]; then flag=1; fi
if [ "$1" = "production" ]; then flag=1; fi
if [ $flag != 1 ]; then
echo "env error! type only development or testing or production"
exit -1;
fi
./file/exec.py $1
mv .envrc .envrc.bk
cp ./file/envrc.env .envrc
# creco: Mac, Linux 별로 sed 명령어의 옵션 기능이 달라 분기 처리가 필요
if [ "$machine" = "Mac" ]; then
sed -i "" 's/^/export /g' .envrc;
fi
if [ "$machine" = "Linux" ]; then
sed -i 's/^/export /g' .envrc;
fi
direnv allow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment