#!/usr/bin/env bash # 2018 Luke Shumaker { set -euE source "${BASH_SOURCE[0]%/*}/lib/osi.sh" arg_image=$1 arg_src=$(realpath -ms -- "$2") arg_dst=$3 needs_sudo mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX") trap "rmdir -- ${mountpoint@Q}" EXIT with_mount "$arg_image" "$mountpoint" sudo -u "#${SUDI_UID}" -- cp -aT -- "$mountpoint/$src" "$dst" }