aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-17 10:50:58 +0800
committertypebrook <typebrook@gmail.com>2020-03-17 15:43:35 +0800
commit6ecc40ac30c7e9d998dd71eccc39f64d3775497c (patch)
tree8dba85cc44b5657c3d7685225226c516ea966c9e
parent8de56c0bf670eed2140ae61ccdb3acbf4e985e76 (diff)
Fix potential error when getting ID from a given index
Originally, if user gives command like 'gist .', _gist_id() still returns true
-rwxr-xr-xgist4
1 files changed, 2 insertions, 2 deletions
diff --git a/gist b/gist
index 2b74732..ae9596a 100755
--- a/gist
+++ b/gist
@@ -406,8 +406,8 @@ _repo_url() {
406 406
407# Get gist id from index files 407# Get gist id from index files
408_gist_id() { 408_gist_id() {
409 GIST_ID=$( (grep -hs '' $INDEX || true) | sed -n -e "/^$1 / p" | cut -d' ' -f2 | sed -E -e 's#.*/##') 409 GIST_ID=$(sed -n -e "/^$1 / p" $INDEX | cut -d' ' -f2 | sed -E -e 's#.*/##')
410 if [[ -z $GIST_ID ]]; then 410 if [[ -z $GIST_ID || ! $1 =~ [0-9a-z]+ ]]; then
411 echo -e "$(hint=false _show_list | sed -Ee 's/^( *[0-9a-z]+)/\\033[5m\1\\033[0m/')" 411 echo -e "$(hint=false _show_list | sed -Ee 's/^( *[0-9a-z]+)/\\033[5m\1\\033[0m/')"
412 echo 412 echo
413 echo -e "Not a valid index: \e[33m$1\e[0m" 413 echo -e "Not a valid index: \e[33m$1\e[0m"