You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to get your thoughts on doing the following for all .sh scripts installed into the build/ tree and into the OPAM_SWITCH_PREFIX tree:
convert them to LF endings if CRLF. CR is not part of the POSIX standard, and some Windows shells (ie. MSYS2 dash.exe) are purist in adhering to POSIX standard. This avoids the need to have a .gitattributes file (ex. https://github.com/diskuv/dkml-installer-ocaml/blob/main/.gitattributes#L22) when checking out a project using git on Windows.
If and only if the script has a shebang from the following list:
#!/bin/bash
#!/bin/sh
#!/usr/bin/env sh
#!/usr/bin/env bash
replace the shebang with the output of command -v sh or command -v bash or follow the POSIX search algorithm on getconf PATH
The POSIX standard for installing scripts is at https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_16. The detection of the correct shell can be done at compile time (ex. opam$ ./configure --bash-shell /bin/bash --posix-shell /bin/sh) or be an opam global variable ... not sure. But the default of /bin/bash and /bin/sh will almost always work.
I realize this may not be backwards compatible as proposed; perhaps there is a way to make it backwards compatible. For example, instead of "all .sh scripts" it could be an explicit .opam field like build_scripts: [ "configure" ].
Personally, if there was an opam global variable I'd set it to the full path to the MSYS2 dash.exe (that is the portable shell for MSYS2) and the full path to MSYS bash.exe so whatever weirdness a Diskuv OCaml Windows user has in their PATH (ex. Cygwin, Git Bash, Chocolatey, etc), the opam installed scripts just work.
The text was updated successfully, but these errors were encountered:
jonahbeckford
changed the title
opam-installer: Consider following POSIX standards when installing .sh scripts
Consider following POSIX standards when installing .sh scripts
Feb 25, 2023
I'd like to get your thoughts on doing the following for all
.sh
scripts installed into thebuild/
tree and into theOPAM_SWITCH_PREFIX
tree:dash.exe
) are purist in adhering to POSIX standard. This avoids the need to have a.gitattributes
file (ex. https://github.com/diskuv/dkml-installer-ocaml/blob/main/.gitattributes#L22) when checking out a project usinggit
on Windows.#!/bin/bash
#!/bin/sh
#!/usr/bin/env sh
#!/usr/bin/env bash
replace the shebang with the output of
command -v sh
orcommand -v bash
or follow the POSIX search algorithm ongetconf PATH
The POSIX standard for installing scripts is at https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_16. The detection of the correct shell can be done at compile time (ex.
opam$ ./configure --bash-shell /bin/bash --posix-shell /bin/sh
) or be an opam global variable ... not sure. But the default of/bin/bash
and/bin/sh
will almost always work.This:
I realize this may not be backwards compatible as proposed; perhaps there is a way to make it backwards compatible. For example, instead of "all
.sh
scripts" it could be an explicit.opam
field likebuild_scripts: [ "configure" ]
.Personally, if there was an opam global variable I'd set it to the full path to the MSYS2
dash.exe
(that is the portable shell for MSYS2) and the full path to MSYSbash.exe
so whatever weirdness a Diskuv OCaml Windows user has in their PATH (ex. Cygwin, Git Bash, Chocolatey, etc), the opam installed scripts just work.The text was updated successfully, but these errors were encountered: