diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-07-30 20:22:10 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-07-30 20:22:10 +0100 |
commit | fdba713eea76ecaf1d5c9829b1b4a6c511d95989 (patch) | |
tree | 435ba51bf384715a26da70ec102871eaeb8289aa |
initial commit
-rwxr-xr-x | burrow | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -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 + |