printf -v is an illegal option, in Bitbucket pipeline. And a question about <<
3
votes
1
answer
1628
views
Hello I'm brand new to shell scripting, so sorry if this is trivial.
How do you use
printf
command with the -v
option?
In our deployment.sh
file we have this line
printf -v BITBUCKET_COMMIT_str %q "$BITBUCKET_COMMIT"
echo 'Initializing new deployment'
printf -v BITBUCKET_COMMIT_str %q "$BITBUCKET_COMMIT"
echo "commit string $BITBUCKET_COMMIT_str"
When the Bitbucket pipeline runs, it always fails at this line. With the error printf -v is an illegal option
.
Error from Bitbucket
Initializing new deployment
commit string
deployment.sh: 28: printf: Illegal option -v
bash: -c: line 1: syntax error: unexpected end of file
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! XXXXX deploy: sh deployment.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the XXXX deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/XXX-debug.log
I've tested the printf -v
command in a local terminal and it works fine, so I don't know why it doesn't work in the Bitbucket build pipeline. I've tried replacing printf
with just a variable, but then I get a syntax error later on in the file. I think that's because we try to use the variable as in input for another command
```
"bash -s $BITBUCKET_COMMIT_str" > The code inside the
HERE block seems to run. But from what I understand about the
<<` that change doesn't really make sense.
Any help would be greatly appreciated. Most of my team is on holiday so I'm having a tough time with this. Thanks in advance :)
Asked by adam.k
(141 rep)
Jul 7, 2020, 02:13 PM
Last activity: Jul 8, 2020, 08:49 AM
Last activity: Jul 8, 2020, 08:49 AM