You are right, I got the -e execution fail.
I forgot about the quoted here-document, thankyou.
-----
From: Lawrence Velázquez <vq@larryv.me>
To: lisa-asket@perso.be
Subject: Re: Adding option to select file types
Date: 06/07/2021 02:44:57 Europe/Paris
Cc: help-bash@gnu.org
On Mon, Jul 5, 2021, at 7:47 PM, lisa-asket@perso.be wrote:
> Why does printf complain with the following help displays?
It would be helpful to see these complaint(s).
> Â Â Â Â Â Â Â frmt="%s"
> Â Â Â Â Â Â printf $frmt "Print text surrounding line numbers from named files.\n"
> Â Â Â Â Â Â printf $frmt "-d DIR\n--directory=DIR\n"
> Â Â Â Â Â Â printf $frmt "Â Â Â Directory.\n"
> Â Â Â Â Â Â printf $frmt "-e TYPE\n--extension=TYPE\n"
>       printf $frmt "   Extension defining file type. Multiple file are\n"
> Â Â Â Â Â Â printf $frmt "Â Â Â separated by a comma (e.g. `-e org,texi`).\n"
I am going to guess that the error is coming from this command.
Command substitution -- including the legacy `...` form -- is
performed inside double quotes.
bash-5.1$ printf '%s\n' "foo `date` bar"
foo Mon Jul 5 20:27:46 EDT 2021 bar
Your shell tries to execute the command '-e org,texi', but you
presumably do not have a utility called '-e', so the execution
fails. This unwanted command substitution would not happen if
you used single quotes instead of double quotes.
https://mywiki.wooledge.org/Quotes#Types_of_quoting
> Â Â Â Â Â Â printf $frmt "-p NUM\n--startline=NUM.\n"
> Â Â Â Â Â Â printf $frmt "Â Â Â Start line number.\n"
> Â Â Â Â Â Â printf $frmt "-q NUM\n--stopline=NUM.\n"
> Â Â Â Â Â Â printf $frmt "Â Â Â Stop line number.\n"
I'm not going to address the ineffectual '\n's in the arguments
because this whole approach seems needlessly involved. You might
instead consider using a quoted here-document, which does not have
issues with expansions, substitutions, or apostrophes.
cat <<'EOF'
Print text surrounding line numbers from named files.
-d DIR
--directory=DIR
Directory.
-e TYPE
--extension=TYPE
Extension defining file type. Multiple file are
separated by a comma (e.g. `-e org,texi`).
-p NUM
--startline=NUM.
Start line number.
-q NUM
--stopline=NUM.
Stop line number.
EOF
https://mywiki.wooledge.org/BashGuide/InputAndOutput#Heredocs_And_Herestrings
--
vq