From 508e2cea8b09fee3745d0c03ff8fdf64bed6c48c Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 29 Dec 2017 11:56:38 +0100 Subject: main: default target {host,user} to origin's --- bin/populate | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/populate b/bin/populate index 7f43cf3..addd0d5 100755 --- a/bin/populate +++ b/bin/populate @@ -46,14 +46,16 @@ main() {( fi target=$( + export origin_host + export origin_user echo "$target_spec" | jq -R ' def default(value; f): if . == null then value else f end; def default(value): default(value; .); - match("^(?:([^@]+)@)?([^:/]+)(?::([^/]*))?(/.*)?") + match("^(?:([^@]+)@)?(?:([^:/]+))?(?::([^/]+))?(/.*)?") | { - user: .captures[0].string | default("root"), - host: .captures[1].string, + user: .captures[0].string | default(env.origin_user), + host: .captures[1].string | default(env.origin_host), port: .captures[2].string | default(22; if test("^[0-9]+$") then fromjson else error(@json "bad target port: \(.)") -- cgit v1.2.3