function ec2() {
	if [ ! -d ~/.ec2 ]; then
		mkdir ~/.ec2
		echo Place EC2 profiles in the newly-created ~/.ec2
		return 0
	fi

	if [ "x$1" = "x" ]; then
		echo Available ec2 profiles:
		ls -1 ~/.ec2
		return 0
	fi

	if [ "$1" = "--clear" ]; then
		ec2_reset
		return 0
	fi

	if [ "$1" = "--reset" ]; then
		ec2_reset
		return 0
	fi


	if [ -f ~/.ec2/$1 ]; then
		#[[ $(stat -f%SMp "$1") =~ .w.$ ]] && echo "Error: $1 is group-writable" && return 1
		#[[ $(stat -f%SLp "$1") =~ .w.$ ]] && echo "Error: $1 is world-writable" && return 1
		echo Switching EC2 profile to $1.
		source ~/.ec2/$1
	else
		echo Profile not defined.
		return 1
	fi
}

function ec2_reset() {
	echo Clearing EC2 profile.
	unset AWS_CREDENTIAL_FILE
	unset AWS_DEFAULT_REGION
	unset AWS_ACCESS_KEY_ID
	unset AWS_SECRET_ACCESS_KEY
	unset AWS_DEFAULT_OUTPUT
}

function ec2() {
	if [ ! -d ~/.ec2 ]; then
		mkdir ~/.ec2
		echo Place EC2 profiles in the newly-created ~/.ec2
		return 0
	fi

	if [ "$1" = "clear" ]; then
		echo Clearing EC2 profile.
		unset AWS_CREDENTIAL_FILE
		unset AWS_DEFAULT_REGION
		unset AWS_ACCESS_KEY_ID
		unset AWS_SECRET_ACCESS_KEY
		unset AWS_DEFAULT_OUTPUT
		
		return 0
	fi

	if [ "x$1" = "x" ]; then
		echo Available ec2 profiles:
		ls -1 ~/.ec2
		return 0
	fi

	if [ -f ~/.ec2/$1 ]; then
		echo Switching EC2 profile to $1.
		source ~/.ec2/$1
	else
		echo Profile not defined.
		return 1
	fi
}

--- 
+++ 
@@ -2,6 +2,17 @@
 	if [ ! -d ~/.ec2 ]; then
 		mkdir ~/.ec2
 		echo Place EC2 profiles in the newly-created ~/.ec2
+		return 0
+	fi
+
+	if [ "$1" = "clear" ]; then
+		echo Clearing EC2 profile.
+		unset AWS_CREDENTIAL_FILE
+		unset AWS_DEFAULT_REGION
+		unset AWS_ACCESS_KEY_ID
+		unset AWS_SECRET_ACCESS_KEY
+		unset AWS_DEFAULT_OUTPUT
+		
 		return 0
 	fi
 
@@ -11,20 +22,7 @@
 		return 0
 	fi
 
-	if [ "$1" = "--clear" ]; then
-		ec2_reset
-		return 0
-	fi
-
-	if [ "$1" = "--reset" ]; then
-		ec2_reset
-		return 0
-	fi
-
-
 	if [ -f ~/.ec2/$1 ]; then
-		#[[ $(stat -f%SMp "$1") =~ .w.$ ]] && echo "Error: $1 is group-writable" && return 1
-		#[[ $(stat -f%SLp "$1") =~ .w.$ ]] && echo "Error: $1 is world-writable" && return 1
 		echo Switching EC2 profile to $1.
 		source ~/.ec2/$1
 	else
@@ -32,12 +30,3 @@
 		return 1
 	fi
 }
-
-function ec2_reset() {
-	echo Clearing EC2 profile.
-	unset AWS_CREDENTIAL_FILE
-	unset AWS_DEFAULT_REGION
-	unset AWS_ACCESS_KEY_ID
-	unset AWS_SECRET_ACCESS_KEY
-	unset AWS_DEFAULT_OUTPUT
-}
Move reset stuff to a function
Make the reset commands more option-like
Use clear/reset and synonyms for the same thing
