#Issue with `sed` command within shell script
1 messages ยท Page 1 of 1 (latest)
Hi! ๐
guessing this is what you need :). https://cuelang.org/docs/tutorials/tour/types/stringraw/
script: contents: #"""
# comment1
sed -i 's/DEFINER=[^*]*\*/\*/g' dump.sql
"""#
CUE does not support raw strings in the strictest sense. Instead it allows modifying the escape delimiter by requiring an arbitrary number of hash # signs after the backslash by enclosing a string literal in an equal number of hash signs on either end.
This works for normal and interpolated strings. Quotes do not have to be escaped in such strin...
So, are you saying that I just need to prepend a # to my initial """?
prepend to initial and append/"postpend" to final
๐ So what does the # do then?
It seems to help quite a bit when there are *, #, \and some other problematic chars in the multi-line string. Especially if you need to have the literal sequence \( and don't want it to indicate string interpolation. You just need to adjust how you do interpolation to use same number of hash chars.
Here I'll use ### as example:
// The first time you run the hello
// action as `dagger do hello --log-format plain`,
// make sure to run `dagger project update` first,
// so that all required dependencies are available.
package hello
import (
"dagger.io/dagger"
"universe.dagger.io/bash"
"universe.dagger.io/alpine"
)
dagger.#Plan & {
client: env: GREETING: string
actions: {
_alpine: alpine.#Build & {
packages: bash: _
}
// Hello world
hello: bash.#Run & {
input: _alpine.output
script: contents: ###"""
# this is a comment
echo 'DEFINER=redactablestuff*DEFINER=redactablestuff*' > dump.sql
sed -i 's/DEFINER=[^*]*\*/\*/g' dump.sql
cat dump.sql
echo "Hello \###(client.env.GREETING)!"
"""###
always: true
}
}
}
GREETING=world dagger-cue do hello --log-format plain