From 6c22a135015a9e5f54050d5c73bbde0daee3538a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 26 Jan 2017 01:21:38 -0500 Subject: hangman-helper: avoid using a temporary file --- hangman-helper.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/hangman-helper.sh b/hangman-helper.sh index 1e65969..3ed1c17 100644 --- a/hangman-helper.sh +++ b/hangman-helper.sh @@ -14,13 +14,10 @@ word=$1 not=$2 flag=$3 -temp="$(mktemp --tmpdir "${0##*/}.XXXXXXXXXX")" -trap "rm -f -- $(printf '%q' "$temp")" EXIT - -grep -ix "$word" /usr/share/dict/words | grep -iv "['$not]" > "$temp" - -if [[ "$flag" = '-l' ]]; then - cat "$temp" | tr 'A-Z' 'a-z' | sed 's/\(.\)/\1\n/'g | sort | uniq -c | sort -n -else - cat "$temp" -fi +grep -ix "$word" /usr/share/dict/words | grep -iv "['$not]" | { + if [[ "$flag" = '-l' ]]; then + tr 'A-Z' 'a-z' | sed 's/\(.\)/\1\n/'g | sort | uniq -c | sort -n + else + cat + fi +} -- cgit v1.2.3