Refactor: join strings in shell instead of relying on paste
這個提交存在於:
父節點
e0bc09679e
當前提交
7b1e34f625
共有 1 個檔案被更改,包括 16 行新增 和 5 行删除
21
cassh.sh
21
cassh.sh
|
@ -92,6 +92,19 @@ format()
|
|||
echo "$_out"
|
||||
}
|
||||
|
||||
strjoin()
|
||||
{
|
||||
_c=$1
|
||||
shift
|
||||
|
||||
_out=
|
||||
for _s; do
|
||||
_out=${_out:+$_out$_c}$_s
|
||||
done
|
||||
|
||||
echo "$_out"
|
||||
}
|
||||
|
||||
main_issue()
|
||||
{
|
||||
hflag=
|
||||
|
@ -175,13 +188,11 @@ main_mkfile()
|
|||
|
||||
case $file in
|
||||
authorized_keys)
|
||||
options=$(printf "%s\n" cert-authority "$@" | paste -sd , -)
|
||||
printf "%s " "$options"
|
||||
printf "%s " "$(strjoin , cert-authority "$@")"
|
||||
;;
|
||||
known_hosts)
|
||||
hostnames=$(printf "%s\n" "$@" | paste -sd , -)
|
||||
if [ -n "$hostnames" ]; then
|
||||
printf "@cert-authority %s " "$hostnames"
|
||||
if [ $# -gt 0 ]; then
|
||||
printf "@cert-authority %s " "$(strjoin , "$@")"
|
||||
else
|
||||
printf "@cert-authority "
|
||||
fi
|
||||
|
|
載入中…
新增表格
新增連結
新增問題並參考