diff options
author | Hsieh Chin Fan <typebrook@gmail.com> | 2020-06-29 13:42:53 +0800 |
---|---|---|
committer | Hsieh Chin Fan <typebrook@gmail.com> | 2020-06-29 13:42:53 +0800 |
commit | 3ede734129c951d15695fb80f4ad9dc5031ac72d (patch) | |
tree | e4ac46ec63f858deeafc768fc476e8ee766cdfe8 | |
parent | 6769bf8cbc43efb557c5df698e8954f6c81e2c44 (diff) |
Feed STDIN only to function tac
-rwxr-xr-x | gist | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 | } |
93 | tac() { sed -e '1! G; h; $!d' $1; } # An easy way to reverse file content both on Linux and Darwin | 93 | tac() { sed -e '1! G; h; $!d'; } # An easy way to reverse file content both on Linux and Darwin |
94 | mtime() { | 94 | mtime() { |
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; } |