Skip to content

Commit

Permalink
WIP: add $HOSTTYPE and $OSTYPE
Browse files Browse the repository at this point in the history
Bash has those implicit variables set. Do you think it's worth having
them in here as well? I don't have the full mapping but happy to keep
digging.
  • Loading branch information
zimbatm committed Sep 7, 2022
1 parent b00be20 commit 2037f55
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions interp/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"math/rand"
"os"
"path/filepath"
"runtime"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -617,10 +618,23 @@ func (r *Runner) Reset() {
r.setVarString("IFS", " \t\n")
r.setVarString("OPTIND", "1")

r.setVarString("HOSTTYPE", goos2hosttype[runtime.GOOS])
r.setVarString("OSTYPE", goarch2ostype[runtime.GOARCH])

r.dirStack = append(r.dirStack, r.Dir)
r.didReset = true
}

// FIXME: add more goarch and goos
var goos2hosttype = map[string]string{
"linux": "linux-gnu",
"darwin": "darwin17.7.0",
}
var goarch2ostype = map[string]string{
"386": "i686",
"amd64": "x86_64",
}

// exitStatus is a non-zero status code resulting from running a shell node.
type exitStatus uint8

Expand Down

0 comments on commit 2037f55

Please sign in to comment.