[Cialug] sed question
Adam Hill
adam at diginc.us
Thu Sep 22 23:48:09 UTC 2022
Run with `set -x` on, interpolation and quoting bugs can't hide from bash
debug mode.
On Wed, Sep 21, 2022 at 9:58 AM Todd Walton <tdwalton at gmail.com> wrote:
> What am I doing wrong here? I set two variables and then try to use them in
> a sed line to update a file. But I get "unterminated s command". I'm sure
> it's some stupid shell quoting thing.
>
> > todd:[~]> printf -v starparen "\x2A\x29"
> >
> > todd:[~]> printf -v gitrun
> '%s\n%s\n%s\x22%s\x22\n%s\x22\x24%s\x22\n%s\n\n%s' "gitlab-runner)" "
> shift" " echo " "Running Runner" " gitlab-runner " "{@}" "
> ;;" " *)"
> >
> > todd:[~]> echo ${starparen}
> > *)
> >
> > todd:[~]> echo "${gitrun}"
> > gitlab-runner)
> > shift
> > echo "Running Runner"
> > gitlab-runner "${@}"
> > ;;
> >
> > *)
> >
> > todd:[~]> sed -i.bak "s,${starparen},${gitrun},g" script.sh
> > sed: -e expression #1, char 19: unterminated 's' command
>
> Any suggestions? Any ideas about what's going awry?
>
> --
> Todd
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
>
More information about the Cialug
mailing list