#Issue with `sed` command within shell script

1 messages ยท Page 1 of 1 (latest)

sharp wyvern
#

Hi, I am currently trying to include the line:

sed -i 's/DEFINER=[^*]*\*/\*/g' dump.sql into my script: contents: """ section, but am getting an error:

ERROR system | failed to load plan: unknown escape sequence:

Any ideas on how I can modify the sed line so that Cue doesn't complain please?

Thanks

patent forge
#

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
  """#
sharp wyvern
#

So, are you saying that I just need to prepend a # to my initial """?

patent forge
#

prepend to initial and append/"postpend" to final

sharp wyvern
#

๐Ÿ™‚ So what does the # do then?

patent forge
#

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