diff options
-rwxr-xr-x | bin/populate | 8 |
1 files 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: \(.)") |