From fdba713eea76ecaf1d5c9829b1b4a6c511d95989 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 30 Jul 2018 20:22:10 +0100 Subject: initial commit --- burrow | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 burrow diff --git a/burrow b/burrow new file mode 100755 index 0000000..be0739f --- /dev/null +++ b/burrow @@ -0,0 +1,35 @@ +#!/bin/sh + +### read from $1 and print on stdout a list of DIR selectors +### one per line, terminated by a line with ".\r\n" +## function +get_dirs(){ + OLDIFS=$IFS + #IFS=$'\t\n' +## IFS="$(echo t | tr t \\t) +##" + IFS="|" + while read name sel host port; do +## echo " --- name: \"$name\"" +## echo " --- sel: \"$sel\"" +## echo " --- host: \"$host\"" +## echo " --- port: \"$port\"" + TYPE=$(echo "$name" | cut -c 1) +## echo " --- TYPE \"$TYPE\"" +## echo "$TYPE, $name, $sel, $host, $port" + [ "${TYPE}" = "1" ] && { + port=$(echo $port | sed -r -e 's/\r//g') + dir_id=$(echo "${TYPE}|${sel}|${host}|${port}" | sed 's/^1||/1|\/|/g') + sid=$(echo "${dir_id}" | sha256sum | cut -d " " -f 1 ) + echo "${dir_id}|${sid}" + } + done + IFS=$OLDIFS +} + + +FIN=${1:-"/dev/stdin"} +SRC="$2" + +cat "$FIN" | sed -r -e 's/\t/|/g' | get_dirs + -- cgit v1.2.3