View Single Post
Old 04-29-2018, 04:47 AM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Wow, this is just... precious. (Noticed when I saw https://github.com/kovidgoyal/calibr...ad5f0d79f8bba2 show up, really made my day BTW. )

I hate to burst your bubble again, by the way... but Debian, and therefore Ubuntu, provides at least one officially supported /bin/sh implementation whose sole reason for existing is to provide the strictly POSIX-only functionality required for the most minimal shell ever. And... Debian being Debian, their policies specify POSIX SUSv3 (2004) as the target conformity thingy... which means this debian-specific shell does not support `command -v` as per HERE.

(Let's leave aside the issue of their running to SUSv3 spec, while at the same time claiming the local keyword is so important as to merit special exceptions... then also claiming they desperately need echo -n even though printf is already mandated by POSIX.)

(Why do I know this? I once made the stupid mistake of trying to improve Debian code: https://bugs.debian.org/cgi-bin/bugr...cgi?bug=889676)

Yes, they're freaking insane. But this script is meant to workaround Debian/Ubuntu bugs... so all things considered I would seriously recommend instructing people to run this script using GNU bash just in case. Or simply trying to find the location of a python3 binary to workaround not having a python one will fail for the poor souls who installed posh as their Policy-compliant Ordinary SHell.

You could, of course, try to rely on the "which" binary which is not guaranteed to exist anywhere (Debian has it as essential, Arch has it in base but people keep removing it anyway). Or just hardcode the possibilities in /usr/bin/
But I think it makes more sense to just assume a decent shell like bash, which really should be on any Linux system without exception.

Well, so much for universal scripting languages on Linux. Turns out you always need GNU bash in the end.

...

Minor errata:
Code:
$PYTHON -c "stuff; script_launch()" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" <<'HEREDOC'
Could be replaced by:
Code:
$PYTHON -c "stuff; script_launch()" "$@" <<'HEREDOC'
Simpler, more readable, works even in POSIX (both the decade-old Debian standard and the 5-year-old standard they vaguely intend to upgrade to, probably by the year 2030), arguably offers more future-proofing. Silently dropping additional args should be done in one place, inside the wrapped python script.

Last edited by eschwartz; 04-29-2018 at 04:52 AM.
eschwartz is offline   Reply With Quote