diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-18 17:52:29 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-18 18:33:30 +0800 |
| commit | f7c727ac77983061cac70a957e12808c8e04a7cf (patch) | |
| tree | 8a201a6d92dd4f5a59f7c18b5f1b1b7e30601a67 | |
| parent | ba7868eec3ff6c9d764ce2fa3dda8943b91c2dc7 (diff) | |
Fix logic error with index prefix
It loses prefix 'p' for newly created private gist
Fow now, decide prefix only in _parse_response()
| -rwxr-xr-x | gist | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -339,7 +339,7 @@ _parse_response() { | |||
| 339 | | while read -r "${INDEX_FORMAT[@]:0:2}" file_url_array public "${INDEX_FORMAT[@]:3:6}"; do | 339 | | while read -r "${INDEX_FORMAT[@]:0:2}" file_url_array public "${INDEX_FORMAT[@]:3:6}"; do |
| 340 | local blob_code; blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -) | 340 | local blob_code; blob_code=$(echo "$file_url_array" | tr ',' '\n' | sed -E -e 's#.*raw/(.*)/.*#\1#' | sort | cut -c -7 | paste -s -d '-' -) |
| 341 | local prefix=$mark; [[ $public == 'False' ]] && prefix=p | 341 | local prefix=$mark; [[ $public == 'False' ]] && prefix=p |
| 342 | [[ -n $1 ]] && local index=${1} || local index=${prefix}${index} | 342 | [[ -n $1 ]] && local index=${1}; index=${prefix}${index} |
| 343 | eval echo $(sed -Ee 's/([^ ]+)/$\1/g' <<<"${INDEX_FORMAT[@]}") | 343 | eval echo $(sed -Ee 's/([^ ]+)/$\1/g' <<<"${INDEX_FORMAT[@]}") |
| 344 | done | 344 | done |
| 345 | } | 345 | } |
| @@ -627,9 +627,9 @@ _edit_gist() { | |||
| 627 | 627 | ||
| 628 | http_data=$(mktemp) | 628 | http_data=$(mktemp) |
| 629 | echo '{' \"description\": \""${DESC//\"/\\\"}"\" '}' > "$http_data" | 629 | echo '{' \"description\": \""${DESC//\"/\\\"}"\" '}' > "$http_data" |
| 630 | new_record=$( http_method PATCH "$GITHUB_API/gists/$GIST_ID" \ | 630 | new_record=$(http_method PATCH "$GITHUB_API/gists/$GIST_ID" \ |
| 631 | | sed -e '1 s/^/[/; $ s/$/]/' \ | 631 | | sed -e '1 s/^/[/; $ s/$/]/' \ |
| 632 | | _parse_response "$1" ) | 632 | | _parse_response "${1#[[:alpha:]]}" ) |
| 633 | [[ -n $new_record ]] && sed -i'' -E -e "/^$1 / s^.+^$new_record^" $INDEX \ | 633 | [[ -n $new_record ]] && sed -i'' -E -e "/^$1 / s^.+^$new_record^" $INDEX \ |
| 634 | && hint=false mark="$1 " _show_list \ | 634 | && hint=false mark="$1 " _show_list \ |
| 635 | || echo 'Fail to modify gist description' | 635 | || echo 'Fail to modify gist description' |