#!/bin/bash
name=$1
value=$2
envfile=$3
if [ "$envfile" == "" ]; then
envfile=~/.env
fi
if [ ! -e $envfile ]; then
touch $envfile
fi
have=$(grep $name $envfile)
if [ "$have" == "" ]; then
echo "$name=$value" >> $envfile
else
sed -ir "s/$name=.*/$name=$value/" $envfile
rm -f ${envfile}r
fi