[LTP] [PATCH v9 2/5] Add script to generate arch(s) dependant syscalls
Petr Vorel
pvorel@suse.cz
Fri Nov 1 18:02:33 CET 2024
> 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..
I would say EOF if quite standard way of using shell + it allows you to use \n
unescaped:
syscall="XXX"
cat > foo.txt <<EOF
printf(\"$syscall %%d"
printf '\n'
EOF
prints into foo.txt:
printf(\"XXX %%d"
printf '\n'
But sure, it's just a suggestion based your comment.
Kind regards,
Petr
> Andrea
More information about the ltp
mailing list