1
0
Эх сурвалжийг харах

Merge pull request #23 from KevCui/master

Replace awk by other commands in order to reduce dependency
Siddharth Dushantha 5 жил өмнө
parent
commit
ae4afe8ca6
2 өөрчлөгдсөн 4 нэмэгдсэн , 5 устгасан
  1. 0 1
      README.md
  2. 4 4
      tmpmail

+ 0 - 1
README.md

@@ -21,7 +21,6 @@ use the `--browser` argument followed by the command needed to launch the web br
 - `w3m`
 - `curl`
 - [`jq`](https://github.com/stedolan/jq)
-- `awk`
 
 ## Installation
 ### Install locally

+ 4 - 4
tmpmail

@@ -2,7 +2,7 @@
 #
 # by Siddharth Dushantha 2020
 #
-# Dependencies: jq, curl, w3m, awk
+# Dependencies: jq, curl, w3m
 #
 
 export LC_ALL=C
@@ -258,15 +258,15 @@ view_recent_email() {
     #
     # This is done by listing all the received email like you
     # normally see on the terminal when running 'tmpmail'.
-    # We then use 'awk' to grab the ID of the most recent
+    # We then grab the ID of the most recent
     # email, which the first line.
-    MAIL_ID=$(list_emails | awk 'NR==3{print $1}')
+    MAIL_ID=$(list_emails | head -3 | tail -1 | cut -d' ' -f 1)
     view_email "$MAIL_ID"
 }
 
 main() {
     # Iterate of the array of dependencies and check if the user has them installed
-    dependencies=(jq w3m curl awk)
+    dependencies=(jq w3m curl)
     for dependency in "${dependencies[@]}"; do
         if ! has "$dependency"; then
             echo "Error: Could not find '${dependency}', is it installed?" >&2