From: Ian Kelling Date: Wed, 18 Jun 2014 01:53:51 +0000 (-0700) Subject: minor perf idiom improvement X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=0a9b2b99289f77d803506dc168b9f69c2c5f7924;p=tee-unique minor perf idiom improvement --- diff --git a/appendu b/appendu index c7455dc..1d9388e 100755 --- a/appendu +++ b/appendu @@ -56,7 +56,7 @@ Appended lines are output to the terminal. readsudo= writesudo= fi - if [[ $@ ]]; then + if (( $# )); then for x in "$@"; do [[ -e "$file" ]] && $readsudo grep -q "^$x$" "$file" || $writesudo tee -a "$file"<<<"$x" done diff --git a/appendu-function b/appendu-function index 40a4edf..a169bd7 100644 --- a/appendu-function +++ b/appendu-function @@ -56,7 +56,7 @@ Appended lines are output to the terminal. readsudo= writesudo= fi - if [[ $@ ]]; then + if (( $# )); then for x in "$@"; do [[ -e "$file" ]] && $readsudo grep -q "^$x$" "$file" || $writesudo tee -a "$file"<<<"$x" done