public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* Perpetual postinstall scripts
@ 2017-07-19 17:11 Achim Gratz
  2017-07-27  5:42 ` [Nitpicks] Non-standard Cygwin-only hashbangs in base-files, biber, hg, xlsx2csv, xmlto scripts Brian Inglis
  0 siblings, 1 reply; 2+ messages in thread
From: Achim Gratz @ 2017-07-19 17:11 UTC (permalink / raw)
  To: cygwin-apps


We're starting to get more and more of these, which is fine, since that
was why they were introduced.  However, I'd like to remind everybody to
not use bash for any postinstall scripts unless you absolutely have to
and especially not for perpetual postinstall scripts.  It is only
slightly less troublesome to script for dash if your script doesn't use
any bashisms, either set PATH=/usr/bin at the beginning of the script or
use absolute path names for all executables.

Since a lot of the perpetual postinstall scripts check a condition to
decide if they should do anything, I'd also repeat my recommendation to
avoid forking subprocesses as much as possible (use builtins instead of
/usr/bin/test for instance) and hand off to terminal executables via
exec.  This drastically increases the chances of things still working OK
if something went wrong with rebasing.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf rackAttack:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Nitpicks] Non-standard Cygwin-only hashbangs in base-files, biber, hg, xlsx2csv, xmlto scripts
  2017-07-19 17:11 Perpetual postinstall scripts Achim Gratz
@ 2017-07-27  5:42 ` Brian Inglis
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Inglis @ 2017-07-27  5:42 UTC (permalink / raw)
  To: cygwin-apps

Hi folks,

Running file(1) detects non-standard Cygwin-only hashbangs in base-files, biber,
hg, xlsx2csv, xmlto scripts.
If standard paths were used, these would be detected and named in file(1) output
as POSIX shell, Perl, Python, etc. scripts.

The use of /usr/bin/sh instead of standard /bin/sh, /bin/python instead of
/usr/bin/python, and /usr/bin/perl.exe instead of /usr/bin/perl could be a
problem if these scripts were used in cross-build environments, and the exec
function did not fall back to a path search for the interpreter.

It would be nice if these could be cleaned up in the next releases, unless there
are reasons for those non-standard paths to avoid use on non-Cygwin platforms.

Also xmlto works only if the default /bin/sh is bash as it uses declare, echo
-e, and test == -- either the hashbang or the bashisms should be fixed: see
bottom for checkbashisms output.

$ file /etc/preremove/base-files.sh /usr/bin/{biber,hg,xlsx2csv,xmlto}
/etc/preremove/base-files.sh: a /usr/bin/sh script, ASCII text executable
/usr/bin/biber:               a /usr/bin/perl.exe  script, UTF-8 Unicode text
executable
/usr/bin/hg:                  a /bin/python script, ASCII text executable
/usr/bin/xlsx2csv:            a /bin/python script, ASCII text executable
/usr/bin/xmlto:               a /usr/bin/sh script, ASCII text executable
$ head -1 /etc/preremove/base-files.sh /usr/bin/{biber,hg,xlsx2csv,xmlto}
==> /etc/preremove/base-files.sh <==
#!/usr/bin/sh

==> /usr/bin/biber <==
#!/usr/bin/perl.exe

==> /usr/bin/hg <==
#!/bin/python

==> /usr/bin/xlsx2csv <==
#!/bin/python

==> /usr/bin/xmlto <==
#!/usr/bin/sh

$ checkbashisms /usr/bin/xmlto
possible bashism in /usr/bin/xmlto line 134 (declare):
declare -a XSL_MODS
possible bashism in /usr/bin/xmlto line 138 (declare):
declare -a CLEANFILES
possible bashism in /usr/bin/xmlto line 583 (echo -e):
  [ "${VERBOSE}" -ge 1 ] && \
   echo -e >&2 "${XSLTPROC_PATH} ${XSLTOPTS} ${SEARCHPATH_FORMATTED} \\\\\n -o
\"${XSLT_PROCESSED}\" \\\\\n \"${STYLESHEET}\" \\\\\n \"${INPUT_FILE}\""
possible bashism in /usr/bin/xmlto line 590 (should be 'b = a'):
  if [ $? == 4 ]
possible bashism in /usr/bin/xmlto line 595 (echo -e):
        echo -e >&2 "${XSLTPROC_PATH} ${XSLTOPTS} ${SEARCHPATH_FORMATTED}\\\\\n
-o \"${XSLT_PROCESSED}\" \\\\\n \"${STYLESHEET}\" \\\\\n \"${INPUT_FILE}\""

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-27  5:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 17:11 Perpetual postinstall scripts Achim Gratz
2017-07-27  5:42 ` [Nitpicks] Non-standard Cygwin-only hashbangs in base-files, biber, hg, xlsx2csv, xmlto scripts Brian Inglis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).