diff --git a/Gopkg.lock b/Gopkg.lock index 2cdc64c9..302e97fa 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -43,12 +43,6 @@ packages = [".","fastwalk"] revision = "95345c4e1c0ebc9d16a3284177f09360f4d20fab" -[[projects]] - branch = "master" - name = "github.com/mvdan/sh" - packages = ["interp","syntax"] - revision = "e6f9238b1f62400b3834f893a4f0088353519e82" - [[projects]] name = "github.com/pmezard/go-difflib" packages = ["difflib"] @@ -58,8 +52,8 @@ [[projects]] name = "github.com/radovskyb/watcher" packages = ["."] - revision = "005eaf39e854c7af9082e63e9df884ad840819c8" - version = "v1.0.1" + revision = "6145e1439b9de93806925353403f91d2abbad8a5" + version = "v1.0.2" [[projects]] name = "github.com/satori/go.uuid" @@ -68,10 +62,10 @@ version = "v1.1.0" [[projects]] + branch = "master" name = "github.com/spf13/pflag" packages = ["."] - revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" - version = "v1.0.0" + revision = "7aff26db30c1be810f9de5038ec5ef96ac41fd7c" [[projects]] name = "github.com/stretchr/testify" @@ -83,13 +77,13 @@ branch = "master" name = "golang.org/x/crypto" packages = ["pbkdf2","scrypt"] - revision = "42ff06aea7c329876e5a0fe94acc96902accf0ad" + revision = "81e90905daefcd6fd217b62423c0908922eadb30" [[projects]] branch = "master" name = "golang.org/x/net" packages = ["context"] - revision = "f5079bd7f6f74e23c4d65efa0f4ce14cbd6a3c0f" + revision = "66aacef3dd8a676686c7ae3716979581e8b03c47" [[projects]] branch = "master" @@ -101,11 +95,17 @@ branch = "v2" name = "gopkg.in/yaml.v2" packages = ["."] - revision = "25c4ec802a7d637f88d584ab26798e94ad14c13b" + revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" + +[[projects]] + branch = "master" + name = "mvdan.cc/sh" + packages = ["interp","syntax"] + revision = "eaf7b83013b7a3dbfe3c627d00e1b9971afc9748" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "e4d557aa8ac5361b90bedf938605af1892ee59538b0770cd416aad772e57e343" + inputs-digest = "10e83efacd30cadfc07b31678375bdf2e6be288a8b9d175768b1f2efc914f5e1" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index f5e42870..c2b26cd5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -80,7 +80,7 @@ [[constraint]] branch = "master" - name = "github.com/mvdan/sh" + name = "mvdan.cc/sh" [[constraint]] branch = "master" diff --git a/execext/exec.go b/execext/exec.go index 4ab1004b..6d1304cc 100644 --- a/execext/exec.go +++ b/execext/exec.go @@ -6,8 +6,8 @@ import ( "io" "strings" - "github.com/mvdan/sh/interp" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/interp" + "mvdan.cc/sh/syntax" ) // RunCommandOptions is the options for the RunCommand func diff --git a/vendor/github.com/radovskyb/watcher/README.md b/vendor/github.com/radovskyb/watcher/README.md index 4fca41b0..c0ef08bc 100644 --- a/vendor/github.com/radovskyb/watcher/README.md +++ b/vendor/github.com/radovskyb/watcher/README.md @@ -8,10 +8,15 @@ Events contain the `os.FileInfo` of the file or directory that the event is based on and the type of event and file or directory path. +[Installation](#installation) +[Features](#features) +[Example](#example) +[Contributing](#contributing) +[Watcher Command](#command) + # Update Event.Path for Rename and Move events is now returned in the format of `fromPath -> toPath` - #### Chmod event is not supported under windows. # Installation @@ -133,6 +138,8 @@ Usage of watcher: pipe event's info to command's stdin -recursive watch folders recursively (default true) + -startcmd + run the command when watcher starts ``` All of the flags are optional and watcher can also be called by itself: diff --git a/vendor/github.com/radovskyb/watcher/watcher.go b/vendor/github.com/radovskyb/watcher/watcher.go index 4c3ebc2b..e486ea0a 100644 --- a/vendor/github.com/radovskyb/watcher/watcher.go +++ b/vendor/github.com/radovskyb/watcher/watcher.go @@ -57,7 +57,7 @@ func (e Op) String() string { return "???" } -// An Event desribes an event that is received when files or directory +// An Event describes an event that is received when files or directory // changes occur. It includes the os.FileInfo of the changed file or // directory and the type of event that's occurred and the full path of the file. type Event struct { diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index 6f1fc300..7b84e2cd 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -556,6 +556,10 @@ func UnquoteUsage(flag *Flag) (name string, usage string) { name = "int" case "uint64": name = "uint" + case "stringSlice": + name = "strings" + case "intSlice": + name = "ints" } return diff --git a/vendor/gopkg.in/yaml.v2/LICENSE b/vendor/gopkg.in/yaml.v2/LICENSE index 866d74a7..8dada3ed 100644 --- a/vendor/gopkg.in/yaml.v2/LICENSE +++ b/vendor/gopkg.in/yaml.v2/LICENSE @@ -1,13 +1,201 @@ -Copyright 2011-2016 Canonical Ltd. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - http://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/mvdan/sh/.travis.yml b/vendor/mvdan.cc/sh/.travis.yml similarity index 81% rename from vendor/github.com/mvdan/sh/.travis.yml rename to vendor/mvdan.cc/sh/.travis.yml index c58cee7d..9e3d467f 100644 --- a/vendor/github.com/mvdan/sh/.travis.yml +++ b/vendor/mvdan.cc/sh/.travis.yml @@ -1,8 +1,10 @@ language: go go: - - 1.7.x - 1.8.x + - 1.9.x + +go_import_path: mvdan.cc/sh before_install: - go get -u github.com/mattn/goveralls diff --git a/vendor/github.com/mvdan/sh/LICENSE b/vendor/mvdan.cc/sh/LICENSE similarity index 100% rename from vendor/github.com/mvdan/sh/LICENSE rename to vendor/mvdan.cc/sh/LICENSE diff --git a/vendor/github.com/mvdan/sh/README.md b/vendor/mvdan.cc/sh/README.md similarity index 85% rename from vendor/github.com/mvdan/sh/README.md rename to vendor/mvdan.cc/sh/README.md index 82b33182..a10da368 100644 --- a/vendor/github.com/mvdan/sh/README.md +++ b/vendor/mvdan.cc/sh/README.md @@ -1,19 +1,23 @@ # sh -[![GoDoc](https://godoc.org/github.com/mvdan/sh?status.svg)](https://godoc.org/github.com/mvdan/sh) +[![GoDoc](https://godoc.org/mvdan.cc/sh?status.svg)](https://godoc.org/mvdan.cc/sh) [![Build Status](https://travis-ci.org/mvdan/sh.svg?branch=master)](https://travis-ci.org/mvdan/sh) [![Coverage Status](https://coveralls.io/repos/github/mvdan/sh/badge.svg?branch=master)](https://coveralls.io/github/mvdan/sh) A shell parser, formatter and interpreter. Supports [POSIX Shell], -[Bash] and [mksh]. Requires Go 1.7 or later. +[Bash] and [mksh]. Requires Go 1.8 or later. + +**Please note that the import paths have been moved from +`github.com/mvdan/sh/...` to `mvdan.cc/sh/...` for 2.0.** This will help +future-proof the project by making it depend less on GitHub. ### shfmt - go get -u github.com/mvdan/sh/cmd/shfmt + go get -u mvdan.cc/sh/cmd/shfmt `shfmt` formats shell programs. It can use tabs or any number of spaces to indent. See [canonical.sh](syntax/canonical.sh) for a quick look at -its style. +its default style. You can feed it standard input, any number of files or any number of directories to recurse into. When recursing, it will operate on `.sh` @@ -22,7 +26,8 @@ operate on files with no extension and a shell shebang. shfmt -l -w script.sh -Use `-i N` to indent with a number of spaces instead of tabs. +Use `-i N` to indent with a number of spaces instead of tabs. There are +other formatting options - see `shfmt -h`. Packages are available for [Arch], [Homebrew], [NixOS] and [Void]. @@ -44,7 +49,7 @@ validity: ### gosh - go get -u github.com/mvdan/sh/cmd/gosh + go get -u mvdan.cc/sh/cmd/gosh Experimental non-interactive shell that uses `interp`. Work in progress, so don't expect stability just yet. @@ -93,7 +98,7 @@ the parser and the printer. To get started, run: [posix shell]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html [bash]: https://www.gnu.org/software/bash/ [mksh]: https://www.mirbsd.org/mksh.htm -[examples]: https://godoc.org/github.com/mvdan/sh/syntax#pkg-examples +[examples]: https://godoc.org/mvdan.cc/sh/syntax#pkg-examples [arch]: https://aur.archlinux.org/packages/shfmt/ [homebrew]: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/shfmt.rb [nixos]: https://github.com/NixOS/nixpkgs/blob/HEAD/pkgs/tools/text/shfmt/default.nix diff --git a/vendor/github.com/mvdan/sh/interp/arith.go b/vendor/mvdan.cc/sh/interp/arith.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/arith.go rename to vendor/mvdan.cc/sh/interp/arith.go index 9999fb0d..d12531de 100644 --- a/vendor/github.com/mvdan/sh/interp/arith.go +++ b/vendor/mvdan.cc/sh/interp/arith.go @@ -6,7 +6,7 @@ package interp import ( "strconv" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) func (r *Runner) arithm(expr syntax.ArithmExpr) int { diff --git a/vendor/github.com/mvdan/sh/interp/builtin.go b/vendor/mvdan.cc/sh/interp/builtin.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/builtin.go rename to vendor/mvdan.cc/sh/interp/builtin.go index a2bd731b..fc1c5e3e 100644 --- a/vendor/github.com/mvdan/sh/interp/builtin.go +++ b/vendor/mvdan.cc/sh/interp/builtin.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) func isBuiltin(name string) bool { diff --git a/vendor/github.com/mvdan/sh/interp/dev.go b/vendor/mvdan.cc/sh/interp/dev.go similarity index 100% rename from vendor/github.com/mvdan/sh/interp/dev.go rename to vendor/mvdan.cc/sh/interp/dev.go diff --git a/vendor/github.com/mvdan/sh/interp/doc.go b/vendor/mvdan.cc/sh/interp/doc.go similarity index 89% rename from vendor/github.com/mvdan/sh/interp/doc.go rename to vendor/mvdan.cc/sh/interp/doc.go index 320a9106..a9a5723d 100644 --- a/vendor/github.com/mvdan/sh/interp/doc.go +++ b/vendor/mvdan.cc/sh/interp/doc.go @@ -7,4 +7,4 @@ // // This package is a work in progress and EXPERIMENTAL; its API is not // subject to the 1.x backwards compatibility guarantee. -package interp +package interp // import "mvdan.cc/sh/interp" diff --git a/vendor/github.com/mvdan/sh/interp/interp.go b/vendor/mvdan.cc/sh/interp/interp.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/interp.go rename to vendor/mvdan.cc/sh/interp/interp.go index 8ec7d0dc..7d7684fe 100644 --- a/vendor/github.com/mvdan/sh/interp/interp.go +++ b/vendor/mvdan.cc/sh/interp/interp.go @@ -18,7 +18,7 @@ import ( "sync" "syscall" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) // A Runner interprets shell programs. It cannot be reused once a diff --git a/vendor/github.com/mvdan/sh/interp/param.go b/vendor/mvdan.cc/sh/interp/param.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/param.go rename to vendor/mvdan.cc/sh/interp/param.go index 18da01ce..bbfc0ec4 100644 --- a/vendor/github.com/mvdan/sh/interp/param.go +++ b/vendor/mvdan.cc/sh/interp/param.go @@ -9,7 +9,7 @@ import ( "unicode" "unicode/utf8" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) func (r *Runner) quotedElems(pe *syntax.ParamExp) []string { diff --git a/vendor/github.com/mvdan/sh/interp/test.go b/vendor/mvdan.cc/sh/interp/test.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/test.go rename to vendor/mvdan.cc/sh/interp/test.go index 1d02ff91..8e565fcd 100644 --- a/vendor/github.com/mvdan/sh/interp/test.go +++ b/vendor/mvdan.cc/sh/interp/test.go @@ -9,7 +9,7 @@ import ( "os/exec" "regexp" - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) // non-empty string is true, empty string is false diff --git a/vendor/github.com/mvdan/sh/interp/test_classic.go b/vendor/mvdan.cc/sh/interp/test_classic.go similarity index 99% rename from vendor/github.com/mvdan/sh/interp/test_classic.go rename to vendor/mvdan.cc/sh/interp/test_classic.go index f4d34c39..7a51e53c 100644 --- a/vendor/github.com/mvdan/sh/interp/test_classic.go +++ b/vendor/mvdan.cc/sh/interp/test_classic.go @@ -4,7 +4,7 @@ package interp import ( - "github.com/mvdan/sh/syntax" + "mvdan.cc/sh/syntax" ) const illegalTok = 0 diff --git a/vendor/github.com/mvdan/sh/syntax/canonical.sh b/vendor/mvdan.cc/sh/syntax/canonical.sh similarity index 100% rename from vendor/github.com/mvdan/sh/syntax/canonical.sh rename to vendor/mvdan.cc/sh/syntax/canonical.sh diff --git a/vendor/github.com/mvdan/sh/syntax/doc.go b/vendor/mvdan.cc/sh/syntax/doc.go similarity index 81% rename from vendor/github.com/mvdan/sh/syntax/doc.go rename to vendor/mvdan.cc/sh/syntax/doc.go index eff8c2fe..803e65e8 100644 --- a/vendor/github.com/mvdan/sh/syntax/doc.go +++ b/vendor/mvdan.cc/sh/syntax/doc.go @@ -3,4 +3,4 @@ // Package syntax implements parsing and formatting of shell programs. // It supports both POSIX Shell and Bash. -package syntax +package syntax // import "mvdan.cc/sh/syntax" diff --git a/vendor/github.com/mvdan/sh/syntax/lexer.go b/vendor/mvdan.cc/sh/syntax/lexer.go similarity index 100% rename from vendor/github.com/mvdan/sh/syntax/lexer.go rename to vendor/mvdan.cc/sh/syntax/lexer.go diff --git a/vendor/github.com/mvdan/sh/syntax/nodes.go b/vendor/mvdan.cc/sh/syntax/nodes.go similarity index 98% rename from vendor/github.com/mvdan/sh/syntax/nodes.go rename to vendor/mvdan.cc/sh/syntax/nodes.go index 4bc170e4..b7560482 100644 --- a/vendor/github.com/mvdan/sh/syntax/nodes.go +++ b/vendor/mvdan.cc/sh/syntax/nodes.go @@ -175,7 +175,6 @@ func (*DeclClause) commandNode() {} func (*LetClause) commandNode() {} func (*TimeClause) commandNode() {} func (*CoprocClause) commandNode() {} -func (*SelectClause) commandNode() {} // Assign represents an assignment to a variable. // @@ -322,9 +321,11 @@ type WhileClause struct { func (w *WhileClause) Pos() Pos { return w.WhilePos } func (w *WhileClause) End() Pos { return posAddCol(w.DonePos, 4) } -// ForClause represents a for clause. +// ForClause represents a for or a select clause. The latter is only +// present in Bash. type ForClause struct { ForPos, DoPos, DonePos Pos + Select bool Loop Loop Do StmtList } @@ -796,16 +797,6 @@ type LetClause struct { func (l *LetClause) Pos() Pos { return l.Let } func (l *LetClause) End() Pos { return l.Exprs[len(l.Exprs)-1].End() } -// SelectClause represents a Bash select clause. -type SelectClause struct { - SelectPos, DoPos, DonePos Pos - Loop WordIter - Do StmtList -} - -func (f *SelectClause) Pos() Pos { return f.SelectPos } -func (f *SelectClause) End() Pos { return posAddCol(f.DonePos, 4) } - func wordLastEnd(ws []*Word) Pos { if len(ws) == 0 { return Pos{} diff --git a/vendor/github.com/mvdan/sh/syntax/parser.go b/vendor/mvdan.cc/sh/syntax/parser.go similarity index 98% rename from vendor/github.com/mvdan/sh/syntax/parser.go rename to vendor/mvdan.cc/sh/syntax/parser.go index e6e8898c..8035c1c4 100644 --- a/vendor/github.com/mvdan/sh/syntax/parser.go +++ b/vendor/mvdan.cc/sh/syntax/parser.go @@ -362,12 +362,10 @@ func (p *Parser) followErrExp(pos Pos, left string) { p.followErr(pos, left, "an expression") } -func (p *Parser) follow(lpos Pos, left string, tok token) Pos { - pos := p.pos +func (p *Parser) follow(lpos Pos, left string, tok token) { if !p.got(tok) { p.followErr(lpos, left, tok.String()) } - return pos } func (p *Parser) followRsrv(lpos Pos, left, val string) Pos { @@ -1324,11 +1322,10 @@ func (p *Parser) doRedirect(s *Stmt) { func (p *Parser) getStmt(readEnd, binCmd bool) (s *Stmt, gotEnd bool) { s = p.stmt(p.pos) - s.Comments, p.accComs = p.accComs, nil if p.gotRsrv("!") { s.Negated = true if p.newLine || stopToken(p.tok) { - p.posErr(s.Pos(), `! cannot form a statement alone`) + p.posErr(s.Pos(), `"!" cannot form a statement alone`) } } if s = p.gotStmtPipe(s); s == nil || p.err != nil { @@ -1385,8 +1382,7 @@ func (p *Parser) getStmt(readEnd, binCmd bool) (s *Stmt, gotEnd bool) { } func (p *Parser) gotStmtPipe(s *Stmt) *Stmt { - s.Comments = append(s.Comments, p.accComs...) - p.accComs = nil + s.Comments, p.accComs = p.accComs, nil switch p.tok { case _LitWord: switch p.val { @@ -1401,7 +1397,7 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt { case "case": s.Cmd = p.caseClause() case "}": - p.curErr(`%s can only be used to close a block`, p.val) + p.curErr(`%q can only be used to close a block`, p.val) case "then": p.curErr(`%q can only be used in an if`, p.val) case "elif": @@ -1425,7 +1421,7 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt { } case "]]": if p.lang != LangPOSIX { - p.curErr(`%s can only be used to close a test`, + p.curErr(`%q can only be used to close a test`, p.val) } case "let": @@ -1643,12 +1639,11 @@ func (p *Parser) loop(fpos Pos) Loop { p.gotSameLine(semicolon) return cl } - wi := p.wordIter("for", fpos) - return &wi + return p.wordIter("for", fpos) } -func (p *Parser) wordIter(ftok string, fpos Pos) WordIter { - wi := WordIter{} +func (p *Parser) wordIter(ftok string, fpos Pos) *WordIter { + wi := &WordIter{} if wi.Name = p.getLit(); wi.Name == nil { p.followErr(fpos, ftok, "a literal") } @@ -1667,11 +1662,11 @@ func (p *Parser) wordIter(ftok string, fpos Pos) WordIter { return wi } -func (p *Parser) selectClause() *SelectClause { - fc := &SelectClause{SelectPos: p.pos} +func (p *Parser) selectClause() *ForClause { + fc := &ForClause{ForPos: p.pos, Select: true} p.next() - fc.Loop = p.wordIter("select", fc.SelectPos) - fc.DoPos = p.followRsrv(fc.SelectPos, "select foo [in words]", "do") + fc.Loop = p.wordIter("select", fc.ForPos) + fc.DoPos = p.followRsrv(fc.ForPos, "select foo [in words]", "do") fc.Do = p.followStmts("do", fc.DoPos, "done") fc.DonePos = p.stmtEnd(fc, "select", "done") return fc diff --git a/vendor/github.com/mvdan/sh/syntax/printer.go b/vendor/mvdan.cc/sh/syntax/printer.go similarity index 97% rename from vendor/github.com/mvdan/sh/syntax/printer.go rename to vendor/mvdan.cc/sh/syntax/printer.go index 13657348..853c966b 100644 --- a/vendor/github.com/mvdan/sh/syntax/printer.go +++ b/vendor/mvdan.cc/sh/syntax/printer.go @@ -21,6 +21,10 @@ func Indent(spaces uint) func(*Printer) { // backslash will be used. func BinaryNextLine(p *Printer) { p.binNextLine = true } +// SwitchCaseIndent will make switch cases be indented. As such, switch +// case bodies will be two levels deeper than the switch itself. +func SwitchCaseIndent(p *Printer) { p.swtCaseIndent = true } + // NewPrinter allocates a new Printer and applies any number of options. func NewPrinter(options ...func(*Printer)) *Printer { p := &Printer{ @@ -55,8 +59,9 @@ type bufWriter interface { type Printer struct { bufWriter - indentSpaces uint - binNextLine bool + indentSpaces uint + binNextLine bool + swtCaseIndent bool wantSpace bool wantNewline bool @@ -627,17 +632,15 @@ func (p *Printer) command(cmd Command, redirs []*Redirect) (startRedirs int) { p.nestedStmts(x.Do, Pos{}) p.semiRsrv("done", x.DonePos, true) case *ForClause: - p.WriteString("for ") + if x.Select { + p.WriteString("select ") + } else { + p.WriteString("for ") + } p.loop(x.Loop) p.semiOrNewl("do", x.DoPos) p.nestedStmts(x.Do, Pos{}) p.semiRsrv("done", x.DonePos, true) - case *SelectClause: - p.WriteString("select ") - p.loop(&x.Loop) - p.semiOrNewl("do", x.DoPos) - p.nestedStmts(x.Do, Pos{}) - p.semiRsrv("done", x.DonePos, true) case *BinaryCmd: p.stmt(x.X) if x.Y.Pos().Line() <= p.line { @@ -690,6 +693,9 @@ func (p *Printer) command(cmd Command, redirs []*Redirect) (startRedirs int) { p.WriteString("case ") p.word(x.Word) p.WriteString(" in") + if p.swtCaseIndent { + p.incLevel() + } for _, ci := range x.Items { var inlineCom *Comment for _, c := range ci.Comments { @@ -732,6 +738,9 @@ func (p *Printer) command(cmd Command, redirs []*Redirect) (startRedirs int) { p.level-- } p.comments(x.Last) + if p.swtCaseIndent { + p.decLevel() + } p.semiRsrv("esac", x.Esac, len(x.Items) == 0) case *ArithmCmd: p.WriteString("((") diff --git a/vendor/github.com/mvdan/sh/syntax/simplify.go b/vendor/mvdan.cc/sh/syntax/simplify.go similarity index 92% rename from vendor/github.com/mvdan/sh/syntax/simplify.go rename to vendor/mvdan.cc/sh/syntax/simplify.go index db904c81..0242e45d 100644 --- a/vendor/github.com/mvdan/sh/syntax/simplify.go +++ b/vendor/mvdan.cc/sh/syntax/simplify.go @@ -8,6 +8,15 @@ import "bytes" // Simplify simplifies a given program and returns whether any changes // were made. // +// The changes currently applied are: +// +// Remove clearly useless parentheses $(( (expr) )) +// Remove dollars from vars in exprs (($var)) +// Remove duplicate subshells $( (stmts) ) +// Remove redundant quotes [[ "$var" == str ]] +// Merge negations with unary operators [[ ! -n $var ]] +// Use single quotes to shorten literals "\$foo" +// // This function is EXPERIMENTAL; it may change or disappear at any // point until this notice is removed. func Simplify(n Node) bool { diff --git a/vendor/github.com/mvdan/sh/syntax/token_string.go b/vendor/mvdan.cc/sh/syntax/token_string.go similarity index 100% rename from vendor/github.com/mvdan/sh/syntax/token_string.go rename to vendor/mvdan.cc/sh/syntax/token_string.go diff --git a/vendor/github.com/mvdan/sh/syntax/tokens.go b/vendor/mvdan.cc/sh/syntax/tokens.go similarity index 100% rename from vendor/github.com/mvdan/sh/syntax/tokens.go rename to vendor/mvdan.cc/sh/syntax/tokens.go diff --git a/vendor/github.com/mvdan/sh/syntax/walk.go b/vendor/mvdan.cc/sh/syntax/walk.go similarity index 98% rename from vendor/github.com/mvdan/sh/syntax/walk.go rename to vendor/mvdan.cc/sh/syntax/walk.go index 0a36eebd..fe040bfb 100644 --- a/vendor/github.com/mvdan/sh/syntax/walk.go +++ b/vendor/mvdan.cc/sh/syntax/walk.go @@ -76,9 +76,6 @@ func Walk(node Node, f func(Node) bool) { case *ForClause: Walk(x.Loop, f) walkStmts(x.Do, f) - case *SelectClause: - Walk(&x.Loop, f) - walkStmts(x.Do, f) case *WordIter: Walk(x.Name, f) walkWords(x.Items, f)