File: git-credential-rbw

package info (click to toggle)
rust-rbw 1.13.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 760 kB
  • sloc: sh: 164; makefile: 14
file content (34 lines) | stat: -rwxr-xr-x 594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -f

[ "$1" = get ] || exit

while read -r line; do
	case $line in
		protocol=*)
			protocol=${line#*=} ;;
		host=*)
			host=${line#*=} ;;
		username=*)
			user=${line#*=} ;;
	esac
done

output=
#shellcheck disable=2154
for arg in \
	"${protocol:+$protocol://}$host" \
	"$host" \
	"${host2=${host%.*}}" \
	"${host2#*.}"
do
	# exit on first good result
	[ -n "$user" ] && output=$(rbw get --full "$arg" "$user") && break
	output=$(rbw get --full "$arg") && break
done || exit

printf '%s\n' "$output" | sed -n '
	1{ s/^/password=/p }
	s/^Username: /username=/p
	s/^URI: /host=/p
	'