From b8635b3b13d377a413655b5be30770fc28baf2bc Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 9 May 2019 15:28:09 -0400 Subject: [PATCH] Set argv0= to allow multi-executable binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some binaries use $0 sniffing to determine what mode to use. So, we want to propagate the argv0 we are using so we can use these programs. A good example is “coreutils” which uses this method: $ tree /nix/store/...-coreutils-8.31 . ├── bin │   ├── [ -> coreutils │   ├── b2sum -> coreutils │   ├── base32 -> coreutils │   ├── base64 -> coreutils │   ├── basename -> coreutils │   ├── basenc -> coreutils │   ├── cat -> coreutils │   ├── chcon -> coreutils │   ├── chgrp -> coreutils │   ├── chmod -> coreutils │   ├── chown -> coreutils │   ├── chroot -> coreutils │   ├── cksum -> coreutils │   ├── comm -> coreutils │   ├── coreutils │   ├── cp -> coreutils │   ├── csplit -> coreutils │   ├── cut -> coreutils │   ├── date -> coreutils │   ├── dd -> coreutils │   ├── df -> coreutils │   ├── dir -> coreutils │   ├── dircolors -> coreutils │   ├── dirname -> coreutils │   ├── du -> coreutils │   ├── echo -> coreutils │   ├── env -> coreutils │   ├── expand -> coreutils │   ├── expr -> coreutils │   ├── factor -> coreutils │   ├── false -> coreutils │   ├── fmt -> coreutils │   ├── fold -> coreutils │   ├── groups -> coreutils │   ├── head -> coreutils │   ├── hostid -> coreutils │   ├── id -> coreutils │   ├── install -> coreutils │   ├── join -> coreutils │   ├── kill -> coreutils │   ├── link -> coreutils │   ├── ln -> coreutils │   ├── logname -> coreutils │   ├── ls -> coreutils │   ├── md5sum -> coreutils │   ├── mkdir -> coreutils │   ├── mkfifo -> coreutils │   ├── mknod -> coreutils │   ├── mktemp -> coreutils │   ├── mv -> coreutils │   ├── nice -> coreutils │   ├── nl -> coreutils │   ├── nohup -> coreutils │   ├── nproc -> coreutils │   ├── numfmt -> coreutils │   ├── od -> coreutils │   ├── paste -> coreutils │   ├── pathchk -> coreutils │   ├── pinky -> coreutils │   ├── pr -> coreutils │   ├── printenv -> coreutils │   ├── printf -> coreutils │   ├── ptx -> coreutils │   ├── pwd -> coreutils │   ├── readlink -> coreutils │   ├── realpath -> coreutils │   ├── rm -> coreutils │   ├── rmdir -> coreutils │   ├── runcon -> coreutils │   ├── seq -> coreutils │   ├── sha1sum -> coreutils │   ├── sha224sum -> coreutils │   ├── sha256sum -> coreutils │   ├── sha384sum -> coreutils │   ├── sha512sum -> coreutils │   ├── shred -> coreutils │   ├── shuf -> coreutils │   ├── sleep -> coreutils │   ├── sort -> coreutils │   ├── split -> coreutils │   ├── stat -> coreutils │   ├── stdbuf -> coreutils │   ├── stty -> coreutils │   ├── sum -> coreutils │   ├── sync -> coreutils │   ├── tac -> coreutils │   ├── tail -> coreutils │   ├── tee -> coreutils │   ├── test -> coreutils │   ├── timeout -> coreutils │   ├── touch -> coreutils │   ├── tr -> coreutils │   ├── true -> coreutils │   ├── truncate -> coreutils │   ├── tsort -> coreutils │   ├── tty -> coreutils │   ├── uname -> coreutils │   ├── unexpand -> coreutils │   ├── uniq -> coreutils │   ├── unlink -> coreutils │   ├── uptime -> coreutils │   ├── users -> coreutils │   ├── vdir -> coreutils │   ├── wc -> coreutils │   ├── who -> coreutils │   ├── whoami -> coreutils │   └── yes -> coreutils └── libexec └── coreutils └── libstdbuf.so 3 directories, 108 files --- model-scripts/tmpx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model-scripts/tmpx.sh b/model-scripts/tmpx.sh index 9c2ec6f..8dfe1c7 100755 --- a/model-scripts/tmpx.sh +++ b/model-scripts/tmpx.sh @@ -72,7 +72,7 @@ go () { fi if $run then - ( . ../env && exec ../run "$@" ) + ( . ../env && exec -a "$0" ../run "$@" ) fi } unpack_env () { : # NOOP