diff --git a/interp/api.go b/interp/api.go index d4960163..0ec4b31f 100644 --- a/interp/api.go +++ b/interp/api.go @@ -185,6 +185,12 @@ func New(opts ...RunnerOption) (*Runner, error) { return nil, err } } + + // turn "on" the default Bash options + for i, opt := range bashOptsTable { + r.opts[len(shellOptsTable)+i] = opt.default_state + } + // Set the default fallbacks, if necessary. if r.Env == nil { Env(nil)(r) @@ -409,7 +415,23 @@ var shellOptsTable = [...]shellOpt{ } var bashOptsTable = [...]bashOpt{ - // Bash options that are "on" by default, sorted alphabetically by name + // supported options, sorted alphabetically by name + { + name: "expand_aliases", + default_state: false, + supported: true, + }, + { + name: "globstar", + default_state: false, + supported: true, + }, + { + name: "nullglob", + default_state: false, + supported: true, + }, + // unsupported options, sorted alphabetically by name { name: "checkwinsize", default_state: true, @@ -425,11 +447,6 @@ var bashOptsTable = [...]bashOpt{ default_state: true, supported: false, }, - { - name: "expand_aliases", - default_state: true, - supported: true, - }, { name: "extquote", default_state: true, @@ -440,11 +457,6 @@ var bashOptsTable = [...]bashOpt{ default_state: true, supported: false, }, - { - name: "globstar", - default_state: true, - supported: true, - }, { name: "hostcomplete", default_state: true, @@ -460,11 +472,6 @@ var bashOptsTable = [...]bashOpt{ default_state: true, supported: false, }, - { - name: "nullglob", - default_state: true, - supported: true, - }, { name: "progcomp", default_state: true, @@ -480,7 +487,6 @@ var bashOptsTable = [...]bashOpt{ default_state: true, supported: false, }, - // unsupported and non-default options, sorted alphabetically by name {name: "assoc_expand_once"}, {name: "autocd"}, {name: "cdable_vars"}, diff --git a/interp/builtin.go b/interp/builtin.go index 66f5417e..6d38326e 100644 --- a/interp/builtin.go +++ b/interp/builtin.go @@ -907,11 +907,15 @@ func mapfileSplit(delim byte, dropDelim bool) func(data []byte, atEOF bool) (adv func (r *Runner) printOptLine(name string, enabled, supported bool) { state := optStatuses[enabled] + // if enabled && supported { + // r.outf("%s\t%s\n", name, state) + // return + // } if supported { r.outf("%s\t%s\n", name, state) return } - r.outf("%s\t%s\t(%q not supported)\n", name, optStatuses[!enabled], state) + r.outf("%s\t%s\t(%q not supported)\n", name, state, optStatuses[!enabled]) } func (r *Runner) readLine(raw bool) ([]byte, error) {