From 6e8475734240d3c241d7affa6571a164b73fd8f6 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 23 May 2022 21:16:54 +0200 Subject: scripts/gather-files: make runnable locally --- scripts/gather-files | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/gather-files b/scripts/gather-files index edf7a8a..0798a41 100755 --- a/scripts/gather-files +++ b/scripts/gather-files @@ -1,6 +1,6 @@ #!/bin/bash -if [ $# -ne 1 ]; then +if [ $# -gt 1 ]; then >&2 echo 'usage: '"$0"' host' exit 1 fi @@ -37,9 +37,13 @@ cmd=$( ) { - ssh "${1}" -t "sudo -s bash -c '${cmd}'" \ - || ssh "${1}" -t "su -c '${cmd}'" \ - | sed 1d + if [ $# -eq 1 ]; then + ssh "${1}" -t "sudo -s bash -c '${cmd}'" \ + || ssh "${1}" -t "su -c '${cmd}'" \ + | sed 1d + else + bash -c "${cmd}" + fi } \ 2>/dev/null \ | tee /dev/stderr \ -- cgit v1.2.3-54-g00ecf