Skip to content

wrapProgram doesn't like '?' when using --prefix #161375

@vs49688

Description

@vs49688

Describe the bug

Having a '?' character in a wrapProgram --prefix value causes that value to be ignored.

Steps To Reproduce

  1. Build this derivation:
{ stdenv, makeWrapper }:
stdenv.mkDerivation {
  name = "bug-example";

  dontUnpack = true;

  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cat <<EOF > $out/bin/bug
    #!/bin/sh
    echo "TESTVAR1 = \$TESTVAR1"
    echo "TESTVAR2 = \$TESTVAR2"
    echo "TESTVAR3 = \$TESTVAR3"
    EOF

    chmod a+x $out/bin/bug

    wrapProgram $out/bin/bug \
      --prefix TESTVAR1 ':' 'aaa:bbb' \
      --prefix TESTVAR2 ':' 'aa?:bbb' \
      --prefix TESTVAR3 ':' 'aaa:bb?'

    runHook postInstall
  '';
}
  1. Run ./result/bin/bug

Expected behavior

A clear and concise description of what you expected to happen.

Expected:

$ ./result/bin/bug 
TESTVAR1 = aaa:bbb
TESTVAR2 = aa?:bbb
TESTVAR3 = aaa:bb?

Actual:

$ ./result/bin/bug 
TESTVAR1 = aaa:bbb
TESTVAR2 = bbb
TESTVAR3 = aaa

Additional context

This is causing problems with Lua packages, specifically when using wrapProgram to set LUA_PATH and LUA_CPATH, as
these often have ? in then, e.g. /nix/store/cqmn2sbmp0j3h2b2bcgb21ys3gqjxnva-lua-5.2.4-env/lib/lua/5.2/?.so

Notify maintainers

@talyz @alyssais

Sorry if wrong people, am using git blame.

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.101, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.6.1`
 - channels(zane): `""`
 - channels(root): `"nixos-22.05pre356180.d5f23787297, nixos-unstable-22.05pre356180.d5f23787297"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions