Skip to content

Commit

Permalink
dev: fix slice bounds panic
Browse files Browse the repository at this point in the history
Squash a bug I introduced in #76189; we were assuming a minimum slice
length when we shouldn't have.

Release note: None
  • Loading branch information
irfansharif committed Feb 9, 2022
1 parent d50b013 commit 4cae4b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=13
DEV_VERSION=14

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
9 changes: 8 additions & 1 deletion pkg/cmd/dev/io/os/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ func (o *OS) ReadFile(filename string) (string, error) {
// WriteFile wraps around ioutil.ReadFile, writing the given contents to
// the given file on disk.
func (o *OS) WriteFile(filename, contents string) error {
command := fmt.Sprintf("echo %q > %s", strings.TrimSpace(contents[:10]), filename)
var command string
{
commandContents := contents
if len(commandContents) > 10 {
commandContents = commandContents[:10] // keeps the logging manageable
}
command = fmt.Sprintf("echo %q > %s", strings.TrimSpace(commandContents), filename)
}
o.logger.Print(command)

_, err := o.Next(command, func() (output string, err error) {
Expand Down

0 comments on commit 4cae4b8

Please sign in to comment.