From: Ian Kelling Date: Fri, 17 Jun 2016 08:20:36 +0000 (-0700) Subject: simplify repo to have one script X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=0a9b742ea262b02479c3b055d2d31df6199fc90f;p=tee-unique simplify repo to have one script --- diff --git a/README b/README index b3829e2..4c5077f 100644 --- a/README +++ b/README @@ -1,12 +1,8 @@ -The main documentation is availiable via --help and near the top of any bash -script files which sit next to this file. +The main documentation is availiable via --help and near the top of the bash +script file which sit next to this file. -Files ending in -function are for sourcing then calling as a function. Files -without -function are exactly the same except they are for calling as a script. +The script file can be stripped of the last line and used as a function +instead of a script. -Patches, bugs, and any feedback is very welcome via gitorious or email to +Patches, bugs, and any feedback is very welcome via email to Ian Kelling . - -This program is also part of a collection of programs, -https://gitorious.org/bash-programs-by-ian, which are unrelated except -having the same author and being being bash programs. diff --git a/teeu-function b/teeu-function deleted file mode 100644 index 91d3e40..0000000 --- a/teeu-function +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# Copyright (C) 2014 Ian Kelling -# This program is under GPL v. 3 or later, see - -teeu() { - local help="Usage: appendu [-h|--help] FILE [LINE] - -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" - return - fi - - if (( ${#@} == 0 )) ; then - echo "teeu error: need 1 or more arguments" - echo "$help" - return 1 - fi - local MAPFILE - (( ${#@} >= 2 )) && MAPFILE="${@:2}" || mapfile -t - for line in "${MAPFILE[@]}"; do - grep -xFq "$line" "$1" &>/dev/null || tee -a "$1" <<<"$line" - done - return 0 -}