From a468c8cdb5a12fce2487ae9816cdb4501ffffa09 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 11 Aug 2014 12:54:40 -0700 Subject: [PATCH] fix bug --- teeu | 7 ++----- teeu-function | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/teeu b/teeu index 5be4b76..9ff55ce 100755 --- a/teeu +++ b/teeu @@ -8,7 +8,6 @@ teeu() { Tee unique. Append each LINE or if none, each stdin line to FILE if it does not exist in FILE. [-h|--help] display this message" - if [[ $1 == --help || $1 == -h ]]; then echo "$help" @@ -20,11 +19,9 @@ Tee unique. Append each LINE or if none, each stdin line to FILE if it does not echo "$help" return 1 fi - local file="$1"; shift - local MAPFILE - mapfile -t - for line in "${@:-$MAPFILE[@]}"; do + (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t + for line in "${$MAPFILE[@]}"; do grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" done return 0 diff --git a/teeu-function b/teeu-function index 5845aff..e4705b7 100644 --- a/teeu-function +++ b/teeu-function @@ -8,7 +8,6 @@ teeu() { Tee unique. Append each LINE or if none, each stdin line to FILE if it does not exist in FILE. [-h|--help] display this message" - if [[ $1 == --help || $1 == -h ]]; then echo "$help" @@ -20,11 +19,9 @@ Tee unique. Append each LINE or if none, each stdin line to FILE if it does not echo "$help" return 1 fi - local file="$1"; shift - local MAPFILE - mapfile -t - for line in "${@:-$MAPFILE[@]}"; do + (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t + for line in "${$MAPFILE[@]}"; do grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" done return 0 -- 2.30.2