Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "wrapper scripts: set (mostly) correct $0"
This reverts commit 06848ee.

Turns out that this breaks e.g. gcc finding its installation path.

% gcc foo.c
gcc: error trying to exec 'cc1': execvp: No such file or directory

% gcc --print-search-dirs
install: /ro/gcc-8.2.0/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.0/
[…]

% ls /ro/gcc-8.2.0/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.0/
ls: cannot access '/ro/gcc-8.2.0/bin/../lib/gcc/x86_64-pc-linux-gnu/8.2.0/': No such file or directory
  • Loading branch information
stapelberg committed Nov 6, 2018
1 parent 8497ab1 commit b517cb3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions cmd/distri/build.go
Expand Up @@ -159,9 +159,6 @@ func buildpkg(hermetic, debug, fuse bool) error {
return nil
}

// We need to strip the path from $0 because shebang evaluation doesn’t pass the
// invoker as $0, but passes the path to the shell script instead.
// See also https://www.in-ulm.de/~mascheck/various/shebang/
var wrapperTmpl = template.Must(template.New("").Funcs(template.FuncMap{
"quoteenv": func(env string) string {
return strings.Replace(env, `=`, `="`, 1) + `"`
Expand All @@ -170,7 +167,7 @@ var wrapperTmpl = template.Must(template.New("").Funcs(template.FuncMap{
{{ range $idx, $env := .Env }}
export {{ quoteenv $env }}
{{ end }}
exec -a "${0##*/}" {{ .Prefix }}/{{ .Bin }} "$@"
exec {{ .Prefix }}/{{ .Bin }} "$@"
`))

func (b *buildctx) serialize() (string, error) {
Expand Down

0 comments on commit b517cb3

Please sign in to comment.