Re: Markup in mail messages
On Sat, May 18, 2024 at 08:26:55PM +0700, Max Nikulin wrote:
> 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.
It has nothing to do with the program being exec-ed. The bug is in the
old implementations of /bin/sh. If you're on Debian, you don't need to
worry about it. There is *no* version of Debian which has a /bin/sh
which has this bug. Only legacy commercial Unix systems have it.
> 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
*sigh* zsh....
Well, once again, there is no version of Debian that uses zsh as its
/bin/sh, so you should be OK here. But if you really want to use the
case $# workaround, I won't say you're wrong.
Reply to: