diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-17 10:50:58 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-17 15:43:35 +0800 |
| commit | 6ecc40ac30c7e9d998dd71eccc39f64d3775497c (patch) | |
| tree | 8dba85cc44b5657c3d7685225226c516ea966c9e | |
| parent | 8de56c0bf670eed2140ae61ccdb3acbf4e985e76 (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-x | gist | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -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" |