aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xgist6
1 files changed, 4 insertions, 2 deletions
diff --git a/gist b/gist
index f4bf032..6ab38fb 100755
--- a/gist
+++ b/gist
@@ -176,19 +176,21 @@ _configure() {
176 if [[ $key == 'user' ]]; then 176 if [[ $key == 'user' ]]; then
177 [[ -z $value ]] && echo 'Must specify username' >&2 && return 1 177 [[ -z $value ]] && echo 'Must specify username' >&2 && return 1
178 elif [[ $key == 'token' ]]; then 178 elif [[ $key == 'token' ]]; then
179 [[ ${#value} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1 179 [[ ${#value} -ne 40 && ! $value =~ ^(\$|\`) ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1
180 elif [[ $key =~ ^(auto_sync|show_untagged)$ ]]; then 180 elif [[ $key =~ ^(auto_sync|show_untagged)$ ]]; then
181 [[ ! $value =~ ^(true|false)$ ]] && echo "$key must be either true or false" >&2 && return 1 181 [[ ! $value =~ ^(true|false)$ ]] && echo "$key must be either true or false" >&2 && return 1
182 elif [[ $key == 'protocol' ]]; then 182 elif [[ $key == 'protocol' ]]; then
183 [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1 183 [[ ! $value =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1
184 elif [[ $key == 'action' ]]; then
185 value="'$2'"
184 fi 186 fi
185 shift && local target=$key="'$*'"
186 else 187 else
187 echo "Not a valid key for configuration, use <$valid_keys> instead." 188 echo "Not a valid key for configuration, use <$valid_keys> instead."
188 return 1 189 return 1
189 fi 190 fi
190 191
191 umask 0077 && touch "$CONFIG" 192 umask 0077 && touch "$CONFIG"
193 local target=$key="$value"
192 sed -i'' -e "/^$key=/ d" "$CONFIG" && [[ -n $target ]] && echo "$target" >> "$CONFIG" 194 sed -i'' -e "/^$key=/ d" "$CONFIG" && [[ -n $target ]] && echo "$target" >> "$CONFIG"
193 cat "$CONFIG" 195 cat "$CONFIG"
194} 196}