aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2020-06-29 13:42:53 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2020-06-29 13:42:53 +0800
commit3ede734129c951d15695fb80f4ad9dc5031ac72d (patch)
treee4ac46ec63f858deeafc768fc476e8ee766cdfe8
parent6769bf8cbc43efb557c5df698e8954f6c81e2c44 (diff)
Feed STDIN only to function tac
-rwxr-xr-xgist6
1 files changed, 3 insertions, 3 deletions
diff --git a/gist b/gist
index a0ee803..44358dc 100755
--- a/gist
+++ b/gist
@@ -90,7 +90,7 @@ tmp_file() {
90 mktemp -p $tmp_dir -t $1.XXXXXX 90 mktemp -p $tmp_dir -t $1.XXXXXX
91 fi 91 fi
92} 92}
93tac() { sed -e '1! G; h; $!d' $1; } # An easy way to reverse file content both on Linux and Darwin 93tac() { sed -e '1! G; h; $!d'; } # An easy way to reverse file content both on Linux and Darwin
94mtime() { 94mtime() {
95 if [[ $(uname) == Darwin ]]; then 95 if [[ $(uname) == Darwin ]]; then
96 stat -x $1 | grep Modify | cut -d' ' -f2- 96 stat -x $1 | grep Modify | cut -d' ' -f2-
@@ -432,7 +432,7 @@ _update_gists() {
432 extra="s0 True b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management" 432 extra="s0 True b0d2e7e67aa50298fdf8111ae7466b56 #bash,#gist NONE README.md@Markdown,gist@Shell 2 30 typebrook 2019-12-26T06:49:40Z 2020-05-15T13:00:31Z [bash-gist] A bash script for gist management"
433 [[ $mark == s ]] && echo $extra >> $INDEX 433 [[ $mark == s ]] && echo $extra >> $INDEX
434 434
435 tac $fetched_records | nl -s' ' \ 435 tac <$fetched_records | nl -s' ' \
436 | while read -r "${INDEX_FORMAT[@]:0:2}" extra; do 436 | while read -r "${INDEX_FORMAT[@]:0:2}" extra; do
437 local prefix='' 437 local prefix=''
438 [[ $public == False ]] && prefix=p; [[ $mark == s ]] && prefix=s 438 [[ $public == False ]] && prefix=p; [[ $mark == s ]] && prefix=s
@@ -448,7 +448,7 @@ _update_gists() {
448_query_user() { 448_query_user() {
449 local fetched_records=$(tmp_file fetched) 449 local fetched_records=$(tmp_file fetched)
450 route=users/$1/gists _fetch_gists_with_pagnation $fetched_records 450 route=users/$1/gists _fetch_gists_with_pagnation $fetched_records
451 tac $fetched_records | nl -s' ' \ 451 tac <$fetched_records | nl -s' ' \
452 | while read -r ${INDEX_FORMAT[@]}; do 452 | while read -r ${INDEX_FORMAT[@]}; do
453 echo $index ${GIST_DOMAIN}/${gist_id} $author $file_num $comment_num $description | cut -c -"$(tput cols)" 453 echo $index ${GIST_DOMAIN}/${gist_id} $author $file_num $comment_num $description | cut -c -"$(tput cols)"
454 done || { echo "Failed to query $1's gists"; exit 1; } 454 done || { echo "Failed to query $1's gists"; exit 1; }