Refactor: join strings in shell instead of relying on paste
This commit is contained in:
parent
e0bc09679e
commit
7b1e34f625
21
cassh.sh
21
cassh.sh
@ -92,6 +92,19 @@ format()
|
|||||||
echo "$_out"
|
echo "$_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strjoin()
|
||||||
|
{
|
||||||
|
_c=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
_out=
|
||||||
|
for _s; do
|
||||||
|
_out=${_out:+$_out$_c}$_s
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$_out"
|
||||||
|
}
|
||||||
|
|
||||||
main_issue()
|
main_issue()
|
||||||
{
|
{
|
||||||
hflag=
|
hflag=
|
||||||
@ -175,13 +188,11 @@ main_mkfile()
|
|||||||
|
|
||||||
case $file in
|
case $file in
|
||||||
authorized_keys)
|
authorized_keys)
|
||||||
options=$(printf "%s\n" cert-authority "$@" | paste -sd , -)
|
printf "%s " "$(strjoin , cert-authority "$@")"
|
||||||
printf "%s " "$options"
|
|
||||||
;;
|
;;
|
||||||
known_hosts)
|
known_hosts)
|
||||||
hostnames=$(printf "%s\n" "$@" | paste -sd , -)
|
if [ $# -gt 0 ]; then
|
||||||
if [ -n "$hostnames" ]; then
|
printf "@cert-authority %s " "$(strjoin , "$@")"
|
||||||
printf "@cert-authority %s " "$hostnames"
|
|
||||||
else
|
else
|
||||||
printf "@cert-authority "
|
printf "@cert-authority "
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user