-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
v0.24.0: broken bash variable evaluation #3935
Comments
Could you post the generated pod? Edit: nm, I'll recreate the issue on my side. |
The script gets expanded to: - args:
- -c
- |
tmpfile="/tekton/scripts/script-0-tqc48"
touch ${tmpfile} && chmod +x ${tmpfile}
cat > ${tmpfile} << 'script-heredoc-randomly-generated-vf6hm'
#!/usr/bin/env bash
set -xe
var1=var1_value
var2=var1
echo $(eval echo \$$$$var2)
script-heredoc-randomly-generated-vf6hm
command:
- sh This is the new script behaviour, expected. Kubernetes rewrites But then the output is: (main) λ k logs -f test-pod-sq7x2
+ var1=var1_value
+ var2=var1
++ eval echo '$16var1'
+++ echo 6var1
+ echo 6var1
6var1 Sigh. OK I'll make a revert commit and reopen #3871 |
Never mind. The 4 dollar signs are tekton. This is so confusing. |
For posterity's sake, here's how the script is rendered prior to 0.24.0:
Note
Kubernetes converted the two dollar signs to a single dollar sign and we somehow lost the backslash. |
Bit more investigation: Kubernetes does replace instances of two dollar signs, "$$", with a single dollar sign, "$" but it also attempts to replace instances of "$(X)" with the contents of env var Long story short the original "fix" was too naive and we should revert this change. |
This reverts commit 9a9f896. Attempting to fix instances of "$$" introduced a new bug in the way bash scripts are interpreted: tektoncd#3935
Expected Behavior
bash variable evaluation works fine.
Actual Behavior
bash variable evaluation is broken.
Steps to Reproduce the Problem
taskrun.yaml:
Taskrun result:
Note: Output should be
var1_value
instead of5var1
.On tekton pipelines before version v0.24.0 it works as expected:
Additional Info
Kubernetes version:
Output of
kubectl version
:The text was updated successfully, but these errors were encountered: