Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- FIELD_SEP="|"
- ROW="src/foo\ bar | git@github.com:foo/foobar.git foo | git@github.com:bar/foobar.git bar | git@github.com:baz/foobar.git baz |"
- # cut out the directory first
- DIR=${ROW%%${FIELD_SEP}*}
- TRIMMED_DIR="$(echo -e "${DIR}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
- ROW="${ROW#*${FIELD_SEP}}"
- echo "> dir: $DIR"
- # loop through all defined repos
- echo "> remotes:"
- while [ "$ROW" ] ;do
- REMOTE=${ROW%%${FIELD_SEP}*}
- TRIMMED_REMOTE=($(echo -e "${REMOTE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'))
- echo "> ${TRIMMED_REMOTE[1]} (${TRIMMED_REMOTE[0]})"
- [ "$ROW" = "$REMOTE" ] && ROW='' || ROW="${ROW#*${FIELD_SEP}}"
- done
- # output:
- #
- # > dir: src/foo\ bar
- # > remotes:
- # > foo (git@github.com:foo/foobar.git)
- # > bar (git@github.com:bar/foobar.git)
- # > baz (git@github.com:baz/foobar.git)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement