1
0
Fork 0

Simplify ssh-sign() a bit

This commit is contained in:
tastytea 2022-04-10 03:16:40 +02:00
parent 5a4e65a545
commit 56fd3d07a8
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
#compdef ssh-sign
_arguments '-f[key file]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '*:file:_files' '-h[short help text]'
_arguments '-f[key file]:filename:_files' '-n[namespace]:namespace:_ssh-sign_namespaces' '-h[short help text]' '*:file:_files'
function _ssh-sign_namespaces()
{

View File

@ -4,13 +4,13 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
zmodload zsh/zutil
local -a keyfile=(-f ~/.ssh/id_ed25519)
local -a namespace=(-n file)
local -a help=()
zparseopts -D -K -- f:=keyfile n:=namespace h=help
if [[ ${#help} -ne 0 ]]; then
print "Usage: ${0} [-h] [-f KEYFILE] [-n NAMESPACE] <file> …"
local -a o_keyfile=(-f ~/.ssh/id_ed25519)
local -a o_namespace=(-n file)
local -a o_help=()
zparseopts -D -K -- f:=o_keyfile n:=o_namespace h=o_help
if [[ ${#o_help} -ne 0 ]]; then
print "usage: ${0} [-h] [-f KEYFILE] [-n NAMESPACE] <FILE> …"
return 0
fi
ssh-keygen -Y sign -f ${keyfile[2]} -n ${namespace[2]} ${@}
ssh-keygen -Y sign ${o_keyfile} ${o_namespace} ${@}