Re: [LTP] [PATCH v9 2/5] Add script to generate arch(s) dependant syscalls

Andrea Cervesato via ltp
2024-11-01T13:24:08Z

Hi,

On 11/1/24 12:30, Petr Vorel wrote:
> Hi Andrea,
>
> ...
>> + for syscall in $(cat ${TEMP}/syscall-names.txt); do
>> + printf "
>> + #ifdef __NR_$syscall
>> + printf(\"$syscall %%d"
>> + # i know the following print is ugly, but dash and bash
>> + # treat double quoted strings in a different way and we
>> + # really need to inject '\n' character in the C code
>> + # rather than carriage return
>> + printf '\\n'
>> + printf "\", __NR_$syscall);
> How about using heredocs? IMHO more compatible way of echo/printf "" for new
> lines:
> cat << EOF
> ...
> EOF
>
> I should have noted that at previous version.
> Hint: looking into tst_test.sh can sometimes help.
>
> Also there is echo/printf '' variant:
> cat << 'EOF'
> EOF
> https://unix.stackexchange.com/questions/462593/how-to-escape-a-character-in-a-heredoc-bash-script/462595#462595
>
> There is also ~EOF - ignore leading whitespace, even for terminating EOF.
>
> Kind regards,
> Petr

This method is so ugly: basically the ending EOF must be in the first
column of the next line, otherwise it won't be parsed. And this breaks
readability of course (probably some debugging). I really would avoid
this way..

Andrea