Skip to content

Commit

Permalink
iii: set infile and outfile variables
Browse files Browse the repository at this point in the history
  • Loading branch information
c00kiemon5ter committed Jan 12, 2013
1 parent 1c322ab commit 8558054
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions iii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ grn="$(tput setaf 2)" # green \003[31m
wht="$(tput setaf 7)" # white \003[37m
rst="$(tput sgr0)" # reset \003[0m -- reset

[ -p "$i/$s/$c/in" ] || exit 1
[ -e "$i/$s/$c/out" ] || { touch "$i/$s/$c/out" || exit 1; }
infile="$i/$s/$c/in"
outfile="$i/$s/$c/out"

tail -f -n "$h" "$i/$s/$c/out" | while IFS= read -r mesg
[ -p "$infile" ] || exit 1
[ -e "$outfile" ] || { touch "$outfile" || exit 1; }

tail -f -n "$h" "$outfile" | while IFS= read -r mesg
do
date="${mesg%% *}" mesg="${mesg#* }"
time="${mesg%% *}" mesg="${mesg#* }"
Expand Down Expand Up @@ -87,8 +90,8 @@ done &
trap "stty '$(stty -g)'; kill -TERM 0" EXIT
stty -echonl -echo

bar="------------------------------------------------------------------------------------"
mark() { printf '%s -!- %.*s\n' "$(date +"%F %R")" "$w" "${bar}${bar}" >>"$i/$s/$c/out"; }
bar="--------------------------------------------------------------------------------"
mark() { printf '%s -!- %.*s\n' "$(date +"%F %R")" "$w" "${bar}${bar}" >>"$outfile"; }

while IFS= read -r input; do
case "$input" in
Expand Down Expand Up @@ -135,5 +138,5 @@ while IFS= read -r input; do
;;
esac
[ -n "$input" ] && printf '%s\n' "$input"
done >"$i/$s/$c/in"
done >"$infile"

0 comments on commit 8558054

Please sign in to comment.