On Fri, Feb 24, 2023 at 10:41:01AM -0500, Wietse Venema wrote:
> I have to retract my comment aobut changes to shells. The behavior
> of backslash-newline inside 'string' (single quotes) is to preserve
> the backslash and the newline i.e. the backslash is mot special and
> that has not changed in the past 10+ years.
>
> Thus, the form
>
> make -f Makefile.init makefiles CCARGS="ccargs stuff \
> more ccargs stuff" \
> other stuff \
> more other stuff
>
> Is the form to use when CCARGS spans multiple lines, and you need
> \\\ to protect " quotes inside CCARGS.
FWIW, by far the simpler solution is to avoid the multiple lines, not
change to a much more complicated quoting regiment.
To build variables incrementally, initialise a shell variable with
some of the data, and then grow it:
FOO="${BEFORE_FOO}$FOO${AFTER_FOO}"
if your shell (e.g. "bash") supports array variables, you can also
incrementally build arrays.
declare -a foo
foo+=(arg1)
foo+=("arg2 has a space")
foo+=('arg3 contains
a new line')
...
i=1; for arg in "${foo[@]}"; do printf "%d: %s\n" $i "$arg"; i=$((i+1));
done
1: arg1
2: arg2 has a space
3: arg3 contains
a new line
or whatever meets your needs at the time, but keep the Postfix "CCARGS", ...
newline free.
--
Viktor.