The console command, when running in interactive mode, will now detect if
the input seems to be an incomplete (but valid enough so far) expression,
and if so will produce another prompt to accept another line of expression
input.
This is primarily to make it easier to paste in multi-line expressions
taken from elsewhere, but it could also be used for manual input.
The support for multi-line _editing_ is limited by the fact that the
readline dependency we use doesn't support multiline input and so we're
currently doing this in spite of that library. Hopefully we'll be able to
improve on that in future either by contributing multi-line editing support
upstream or by switching to a different readline dependency.
The delimiter-counting heuristic employed here is similar to the one used
by HCL itself to decide whether a newline should end the definition of an
attribute, but this implementation is simpler because it doesn't need to
produce error messages or perform any recovery. Instead, it just bails out
if it encounters something strange so that the console session can return
a parse error.
Because some invalid input may cause a user to become "stuck" in a multi-
line sequence, we consider a blank line as intent to immediately try to
evaluate what was entered, and also interpret SIGINT (e.g. Ctrl+C) as
cancellation of multi-line input, assuming that at least one line was
already entered, extending the previous precedent that SIGINT cancels
when at least one character was already entered at the prompt.
This includes the addition of the new "//go:build" comment form in addition
to the legacy "// +build" notation, as produced by gofmt to ensure
consistent behavior between Go versions. The new directives are all
equivalent to what was present before, so there's no change in behavior.
Go 1.17 continues to use the Unicode 13 tables as in Go 1.16, so this
upgrade does not require also upgrading our Unicode-related dependencies.
This upgrade includes the following breaking changes which will also
appear as breaking changes for Terraform users, but that are consistent
with the Terraform v1.0 compatibility promises.
- On MacOS, Terraform now requires macOS 10.13 High Sierra or later.
This upgrade also includes the following breaking changes which will
appear as breaking changes for Terraform users that are inconsistent with
our compatibility promises, but have justified exceptions as follows:
- cidrsubnet, cidrhost, and cidrnetmask will now reject IPv4 CIDR
addresses whose decimal components have leading zeros, where previously
they would just silently ignore those leading zeros.
This is a security-motivated exception to our compatibility promises,
because some external systems interpret zero-prefixed octets as octal
numbers rather than decimal, and thus the previous lenient parsing could
lead to a different interpretation of the address between systems, and
thus potentially allow bypassing policy when configuring firewall rules
etc.
This upgrade also includes the following breaking changes which could
_potentially_ appear as breaking changes for Terraform users, but that do
not in practice for the reasons given:
- The Go net/url package no longer allows query strings with pairs
separated by semicolons instead of ampersands. This primarily affects
HTTP servers written in Go, and Terraform includes a special temporary
HTTP server as part of its implementation of OAuth for "terraform login",
but that server only needs to accept URLs created by Terraform itself
and Terraform does not generate any URLs that would be rejected.
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.
If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00
Renamed from command/console_interactive.go (Browse further)