Skip to content

Commit

Permalink
fix shopt status display
Browse files Browse the repository at this point in the history
  • Loading branch information
riacataquian committed Jun 26, 2022
1 parent 55b2812 commit 3db2bba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
40 changes: 23 additions & 17 deletions interp/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -440,11 +457,6 @@ var bashOptsTable = [...]bashOpt{
default_state: true,
supported: false,
},
{
name: "globstar",
default_state: true,
supported: true,
},
{
name: "hostcomplete",
default_state: true,
Expand All @@ -460,11 +472,6 @@ var bashOptsTable = [...]bashOpt{
default_state: true,
supported: false,
},
{
name: "nullglob",
default_state: true,
supported: true,
},
{
name: "progcomp",
default_state: true,
Expand All @@ -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"},
Expand Down
6 changes: 5 additions & 1 deletion interp/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3db2bba

Please sign in to comment.