Yep, this is so,

But the orginal sed:

sed "s|^$key\($delimiter\+\).*|$key\\1$value_escaped|" "$file" > "\$tmpfile"

only takes care about the count of the delimiter, but not explicit for
whitespaces ...





2014-02-27 9:16 GMT+01:00 Steven Armstrong <notifications@github.com>:

> In cdist/conf/type/__key_value/gencode-remote:
>
> > +$(cat "$__object/parameter/comment_line")
> > +__CDIST_INPUT_END_HERE_MARKER
> > +)"
> > +
> > +tmpfile=\$(mktemp "${file}.cdist.XXXXXXXXXX")
> > +# preserve ownership and permissions by copying existing file over tmpfile
> > +cp -p "$file" "\$tmpfile"
> > +awk -f - "$file" >"\$tmpfile" <<"AWK_EOF"
> > +BEGIN {
> > +    # import variables in a secure way ..
> > +    state=ENVIRON["state"]
> > +    key=ENVIRON["key"]
> > +    delimiter=ENVIRON["delimiter"]
> > +    value=ENVIRON["value"]
> > +    comment=ENVIRON["comment"]
> > +    keydel=key delimiter
>
> Wont this break if there is whitespace between key and the delimiter in
> the file?
> I really would not like to have to know if there are 2 or 3 spaces between
> in $file. What if $user adds an entry with 4 spaces, while I expect them to
> be 2 or 0?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/telmich/cdist/pull/317/files#r10115122>
> .
>