Genady
Genady

Reputation: 35

How to save command in variable and print translated command before execution without bash -x

Using bash script function with a following command, looking for a way to print command for before execution for logging purposes without using bash -x, is that possible ? Problematic part is a last command.

helm upgrade $2 chart --install --wait --timeout $3 $debug "${@:4}"

Would like to print a following:

helm upgrade mypod chart --install --wait --timeout 600s --set key=value

Upvotes: 0

Views: 112

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69218

Why not just turning debug on and off?

set -x
helm upgrade $2 chart --install --wait --timeout $3 $debug "${@:4}"
set +x
other commands...

Upvotes: 2

Related Questions