On 17/05/2024 18:10, Greg Wooledge wrote:
On 17/05/2024 10:16, Karl Vogel wrote:
https://github.com/aaronsw/html2text/ might interest you. It converts
(relatively) sane HTML into Markdown.
I put html2text.py into $HOME/lib and use this to call it:
#!/bin/sh
#<html2mkd: convert reasonable HTML to Markdown
exec /usr/bin/env python $HOME/lib/html2text.py ${1+"$@"}
exit 1
[...]
https://mywiki.wooledge.org/WrapperScript
Short version: "$@" is good enough if your /bin/sh isn't museum-era.
${1+"$@"} works around a bug in some very old shells.
Thanks. I am unsure if a python2 script from 2011 is consistent with a
sh expanding "$@" to empty string, but the reason of the construct might
be just muscle memory or some guide.
The wiki article considers a symlink that was my original idea. It seems
"exit 1" can not ensure certain exit code even if exec fails (at least
with current versions of dash and bash). In addition I see no value of
/usr/bin/env in shell script. It is appropriate for the python script
shebang "#!/usr/bin/env python" (present since its initial commit).
P.S.
Portable shell section in autoconf manual mentions "${1+"$@"}" issues
with zsh (the script above requires /bin/sh explicitly):
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-_0022_0024_0040_0022