Skip to content

perl-for-cntrl-chars #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kubectl-node_shell
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

kubectl=kubectl
version=1.5.2
version=1.5.3
generator=""
node=""
nodefaultctx=0
Expand Down Expand Up @@ -75,7 +75,7 @@ done
if [ $# -gt 0 ]; then
while [ $# -gt 0 ]; do
cmd="$cmd, \"$(echo "$1" | \
awk '{gsub(/\\/,"\\\\");gsub(/"/,"\\\"");gsub(/$/,"\\n");printf last}{last=$0} END{gsub(/\\n/,"",last);printf last}' \
awk '{gsub(/["\\]/,"\\\\&");gsub(/\x1b/,"\\u001b");printf "%s",last;last=$0"\\n"} END{print $0}' \
)\""
shift
done
Expand Down
18 changes: 11 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run_test() {

local expected="$(mktemp)"
local got="$(mktemp)"

if diff --strip-trailing-cr -u <(sh -c "$script") <(set -x; ./kubectl-node_shell $node -- sh -c "$script"); then
echo -e "Result: \e[42mPASS\e[49m"
else
Expand All @@ -22,7 +22,9 @@ if [ -z $1 ]; then
exit -1
fi

case1=$(cat <<\EOT
case=()

case[1]=$(cat <<\EOT
echo $(echo "
hello everybody
I'm a \"baby seal\""
Expand All @@ -31,7 +33,7 @@ I'm a \"baby seal\""
EOT
)

case2=$(cat <<\EOT
case[2]=$(cat <<\EOT

echo "ggg

Expand All @@ -40,7 +42,7 @@ ttt"
EOT
)

case3=$(cat <<\EOT
case[3]=$(cat <<\EOT
echo $(echo "
hello everybody
I'm a \"baby seal
Expand All @@ -52,6 +54,8 @@ really really
EOT
)

run_test "case 1" "$1" "$case1"
run_test "case 2" "$1" "$case2"
run_test "case 3" "$1" "$case3"
case[4]="$(echo -e echo "\e[42mHOLA\e[49m")"

for i in $(seq 1 ${#case[@]}); do
run_test "case $i" "$1" "${case[$i]}"
done