#!/bin/sh # C2-03a: git's GIT_ASKPASS for library sync (packages/library/src/sync.mjs). It answers only the # Username and Password prompts for the configured host and user, and exits 1 on anything else. # The env names the slot path, never the token. printf is a shell builtin, so the token is in no argv. host=$MOSAIC_LIBRARY_HOST user=$MOSAIC_LIBRARY_USER slot=$MOSAIC_LIBRARY_SLOT test -n "$host" && test -n "$user" && test -n "$slot" || exit 1 case $host in *[!a-z0-9.:-]*) exit 1 ;; esac case $user in *[!A-Za-z0-9_.-]*) exit 1 ;; esac case $1 in "Username for 'https://$host': ") printf '%s\n' "$user" ;; "Password for 'https://$user@$host': ") test -f "$slot" && test ! -L "$slot" || exit 1 IFS= read -r token < "$slot" || test -n "$token" || exit 1 test -n "$token" || exit 1 printf '%s\n' "$token" ;; *) exit 1 ;; esac