Skip to content

Avoid #!/usr/bin/env bash scripts

Simon McVittie requested to merge wip/smcv/task209 into main
  • pv-wrap: Don't leave a dangling pointer in cleared WrapPreloadModule

  • pv-wrap: Accept LD_AUDIT and LD_PRELOAD as colon-delimited lists

    This makes it easier to set them up in the wrapper shell scripts without making use of bash-specific features, which are not completely portable.

    For LD_PRELOAD, the separator is either a colon or a space; for LD_AUDIT, the separator is a colon. There is no facility for escaping the separators. This matches the behaviour of the environment variables in glibc ld.so, as implemented in elf/rtld.c.

    The usual reason to prefer separate command-line arguments over parsing is that a single merged argument either requires an escape mechanism or cannot represent certain data (for instance loadable modules with a colon in their filenames), but there is no need to try to support things that glibc doesn't, and glibc doesn't support loadable modules with the separator in their filenames anyway.

  • launch-options.sh: Convert from bash to POSIX shell

    Using bash for a shell script is apparently not entirely portable, because #!/bin/bash is not available on some unconventional OSs like NixOS, while the frequently-recommended alternative #!/usr/bin/env bash might find an unusable version of bash in the PATH. In particular, if the bash in the PATH was installed via Nix, then it relies on RUNPATH for correct operation, but the scout runtime's LD_LIBRARY_PATH defeats that.

  • pv-unruntime: Use pv-wrap --ld-preloads instead of splitting LD_PRELOAD

    This is a prerequisite for converting this script to /bin/sh, because this sort of argument vector manipulation would be difficult to do while preserving relative order without access to more than one array.

  • _v2-entry-point: Use pv-wrap --ld-preloads instead of splitting LD_PRELOAD

    This is a prerequisite for converting this script to /bin/sh, because this sort of argument vector manipulation would be difficult to do while preserving relative order without access to more than one array.

  • _v2-entry-point: Refactor to avoid using bash arrays

    bash is not completely portable, so we have to stick to POSIX /bin/sh, which only has one array, "$@".

  • pv-unruntime: Avoid using bash arrays

    bash is not completely portable, so we have to stick to POSIX /bin/sh, which only has one array, "$@".

  • scripts: Convert from bash to POSIX shell

  • _v2-entry-point: Rely on pressure-vessel providing s-r-launcher-interface

    We are no longer supporting any pressure-vessel releases that didn't.

  • scout-on-soldier: Convert trivial scripts to use POSIX /bin/sh

    These scripts don't use any fancy features from bash, so we can use /bin/sh, which is either bash or something faster (like the dash shell used in Debian and Ubuntu).

  • scout-on-soldier: Use /bin/bash for the main script

    Because this script runs inside the SteamLinuxRuntime_soldier container, we don't need to worry about whether /bin/bash exists or makes sense: we know that it should be the bash from Debian 10, which is what this script was written to target. Use it by its absolute path instead of doing a PATH search, to add a bit more predictability.


/cc @denittis

steamrt/tasks#209

Edited by Simon McVittie

Merge request reports