|
|
@@ -87,6 +87,9 @@ def Disable(self): |
|
|
(None, 'strict-errexit'),
|
|
|
(None, 'strict-array'),
|
|
|
|
|
|
(None, 'vi'),
|
|
|
(None, 'emacs'),
|
|
|
|
|
|
# TODO: Add strict-arg-parse? For example, 'trap 1 2 3' shouldn't be
|
|
|
# valid, because it has an extra argument. Builtins are inconsistent about
|
|
|
# checking this.
|
|
|
@@ -146,8 +149,8 @@ def __init__(self, mem): |
|
|
|
|
|
# shopt -s / -u. NOTE: bash uses $BASHOPTS rather than $SHELLOPTS for
|
|
|
# these.
|
|
|
self.nullglob = False
|
|
|
self.failglob = False
|
|
|
self.nullglob = False
|
|
|
self.failglob = False
|
|
|
|
|
|
#
|
|
|
# OSH-specific options that are not yet implemented.
|
|
|
@@ -161,6 +164,10 @@ def __init__(self, mem): |
|
|
# Don't need flags -e and -n. -e is $'\n', and -n is write.
|
|
|
self.sane_echo = False
|
|
|
|
|
|
# Used for 'set -o vi/emacs'
|
|
|
# Set by the Executor, if available
|
|
|
self.readline = None
|
|
|
|
|
|
def _InitOptionsFromEnv(self, shellopts):
|
|
|
# e.g. errexit:nounset:pipefail
|
|
|
lookup = set(shellopts.split(':'))
|
|
|
@@ -199,6 +206,12 @@ def _SetOption(self, opt_name, b): |
|
|
raise args.UsageError('Invalid option %r' % opt_name)
|
|
|
if opt_name == 'errexit':
|
|
|
self.errexit.Set(b)
|
|
|
elif opt_name in ('vi', 'emacs'):
|
|
|
if self.readline:
|
|
|
self.readline.parse_and_bind("set editing-mode " + opt_name);
|
|
|
else:
|
|
|
# TODO error message copied from 'cmd_exec.py'; refactor?
|
|
|
util.error('Oil was not built with readline/completion.')
|
|
|
else:
|
|
|
# strict-control-flow -> strict_control_flow
|
|
|
opt_name = opt_name.replace('-', '_')
|
|
|
@@ -309,7 +322,7 @@ class DirStack(object): |
|
|
def __init__(self):
|
|
|
self.stack = []
|
|
|
self.Reset()
|
|
|
|
|
|
|
|
|
def Reset(self):
|
|
|
self.stack[:] = [os.getcwd()]
|
|
|
|
|
|
@@ -565,15 +578,15 @@ def _FindCellAndNamespace(self, name, lookup_mode, is_read=False): |
|
|
namespace = self.var_stack[0].vars
|
|
|
return namespace.get(name), namespace
|
|
|
|
|
|
else:
|
|
|
else:
|
|
|
raise AssertionError(lookup_mode)
|
|
|
|
|
|
def SetVar(self, lval, value, new_flags, lookup_mode):
|
|
|
"""
|
|
|
Args:
|
|
|
lval: lvalue
|
|
|
val: value, or None if only changing flags
|
|
|
new_flags: tuple of flags to set: ReadOnly | Exported
|
|
|
new_flags: tuple of flags to set: ReadOnly | Exported
|
|
|
() means no flags to start with
|
|
|
None means unchanged?
|
|
|
scope:
|
|
|
@@ -784,7 +797,7 @@ def GetExported(self): |
|
|
# TODO: This is run on every SimpleCommand. Should we have a dirty flag?
|
|
|
# We have to notice these things:
|
|
|
# - If an exported variable is changed.
|
|
|
# - If the set of exported variables changes.
|
|
|
# - If the set of exported variables changes.
|
|
|
|
|
|
exported = {}
|
|
|
# Search from globals up. Names higher on the stack will overwrite names
|
|
|
@@ -801,7 +814,7 @@ def SetLocalString(mem, name, s): |
|
|
|
|
|
Used for:
|
|
|
1) for loop iteration variables
|
|
|
2) temporary environments like FOO=bar BAR=$FOO cmd,
|
|
|
2) temporary environments like FOO=bar BAR=$FOO cmd,
|
|
|
3) read builtin
|
|
|
"""
|
|
|
assert isinstance(s, str)
|
|
|
|
0 comments on commit
c16d264