add escape_char and escape_space functions

move sshtest function to remote module
rename remote_args to escape_args and user escape_space
master
David Kebler 2024-02-22 13:47:44 -08:00
parent 56e758c0f9
commit e36e658a69
1 changed files with 11 additions and 14 deletions

View File

@ -93,9 +93,18 @@ if [[ -f $1 ]]; then cat $1; else echo "$1"; fi | sed -n '/^\s*$/!p'
# sed -rz 's/^\n+//; s/\n+$/\n/g'
}
remote_args () {
# $(sed 's/ /\\ /g' <<< $i)"
escape_char () {
echo ${1//$2/\\$2}
}
escape_spaces () {
escape_char "$1" " "
}
escape_args () {
local rargs
for i; do rargs="$rargs $(sed 's/ /\\ /g' <<< $i)"; done
for i; do rargs="$rargs $(escape_spaces "$i")"; done
echo $rargs
}
@ -132,18 +141,6 @@ mkrfilename () {
}
sshtest () {
env | grep BASH
echo running on machine: $(hostnamectl hostname)
echo as user:home $(whoami):$HOME
echo argument1 $1
echo argument2 $2
echo remaining arguments: "${@:3}"
echo home directory listing
ls -la ~
}
#rows between matched rows
# sed '1,/firstmatch/d;/secondmatch/,$d'