diff options
author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:27:16 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:27:16 -0800 |
commit | 881d6064d23d9da5c7ff368bc7d41d271290deff (patch) | |
tree | 44d5d948e3f27cc7eff15ec8cd7ee5165d9a7e90 /src/pkg/exec/exec.go | |
parent | d9dfea3ebd51cea89fef8afc6b2377c2958b24f1 (diff) | |
download | golang-881d6064d23d9da5c7ff368bc7d41d271290deff.tar.gz |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
2nd set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/179067
Diffstat (limited to 'src/pkg/exec/exec.go')
-rw-r--r-- | src/pkg/exec/exec.go | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/pkg/exec/exec.go b/src/pkg/exec/exec.go index 8a19f0e8f..8e959e03a 100644 --- a/src/pkg/exec/exec.go +++ b/src/pkg/exec/exec.go @@ -6,16 +6,16 @@ package exec import ( - "os"; - "strings"; + "os" + "strings" ) // Arguments to Run. const ( - DevNull = iota; - PassThrough; - Pipe; - MergeWithStdout; + DevNull = iota + PassThrough + Pipe + MergeWithStdout ) // A Cmd represents a running command. @@ -24,10 +24,10 @@ const ( // or else nil, depending on the arguments to Run. // Pid is the running command's operating system process ID. type Cmd struct { - Stdin *os.File; - Stdout *os.File; - Stderr *os.File; - Pid int; + Stdin *os.File + Stdout *os.File + Stderr *os.File + Pid int } // Given mode (DevNull, etc), return file for child @@ -35,12 +35,12 @@ type Cmd struct { func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) { switch mode { case DevNull: - rw := os.O_WRONLY; + rw := os.O_WRONLY if fd == 0 { rw = os.O_RDONLY } - f, err := os.Open("/dev/null", rw, 0); - return f, nil, err; + f, err := os.Open("/dev/null", rw, 0) + return f, nil, err case PassThrough: switch fd { case 0: @@ -51,16 +51,16 @@ func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) { return os.Stderr, nil, nil } case Pipe: - r, w, err := os.Pipe(); + r, w, err := os.Pipe() if err != nil { return nil, nil, err } if fd == 0 { return r, w, nil } - return w, r, nil; + return w, r, nil } - return nil, nil, os.EINVAL; + return nil, nil, os.EINVAL } // Run starts the binary prog running with @@ -79,8 +79,8 @@ func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) { // of the returned Cmd is the other end of the pipe. // Otherwise the field in Cmd is nil. func Run(argv0 string, argv, envv []string, stdin, stdout, stderr int) (p *Cmd, err os.Error) { - p = new(Cmd); - var fd [3]*os.File; + p = new(Cmd) + var fd [3]*os.File if fd[0], p.Stdin, err = modeToFiles(stdin, 0); err != nil { goto Error @@ -95,7 +95,7 @@ func Run(argv0 string, argv, envv []string, stdin, stdout, stderr int) (p *Cmd, } // Run command. - p.Pid, err = os.ForkExec(argv0, argv, envv, "", &fd); + p.Pid, err = os.ForkExec(argv0, argv, envv, "", &fd) if err != nil { goto Error } @@ -108,7 +108,7 @@ func Run(argv0 string, argv, envv []string, stdin, stdout, stderr int) (p *Cmd, if fd[2] != os.Stderr && fd[2] != fd[1] { fd[2].Close() } - return p, nil; + return p, nil Error: if fd[0] != os.Stdin && fd[0] != nil { @@ -129,7 +129,7 @@ Error: if p.Stderr != nil { p.Stderr.Close() } - return nil, err; + return nil, err } // Wait waits for the running command p, @@ -142,11 +142,11 @@ func (p *Cmd) Wait(options int) (*os.Waitmsg, os.Error) { if p.Pid <= 0 { return nil, os.ErrorString("exec: invalid use of Cmd.Wait") } - w, err := os.Wait(p.Pid, options); + w, err := os.Wait(p.Pid, options) if w != nil && (w.Exited() || w.Signaled()) { p.Pid = -1 } - return w, err; + return w, err } // Close waits for the running command p to exit, @@ -157,14 +157,14 @@ func (p *Cmd) Close() os.Error { // Loop on interrupt, but // ignore other errors -- maybe // caller has already waited for pid. - _, err := p.Wait(0); + _, err := p.Wait(0) for err == os.EINTR { _, err = p.Wait(0) } } // Close the FDs that are still open. - var err os.Error; + var err os.Error if p.Stdin != nil && p.Stdin.Fd() >= 0 { if err1 := p.Stdin.Close(); err1 != nil { err = err1 @@ -180,15 +180,15 @@ func (p *Cmd) Close() os.Error { err = err1 } } - return err; + return err } func canExec(file string) bool { - d, err := os.Stat(file); + d, err := os.Stat(file) if err != nil { return false } - return d.IsRegular() && d.Permission()&0111 != 0; + return d.IsRegular() && d.Permission()&0111 != 0 } // LookPath searches for an executable binary named file @@ -205,9 +205,9 @@ func LookPath(file string) (string, os.Error) { if canExec(file) { return file, nil } - return "", os.ENOENT; + return "", os.ENOENT } - pathenv := os.Getenv("PATH"); + pathenv := os.Getenv("PATH") for _, dir := range strings.Split(pathenv, ":", 0) { if dir == "" { // Unix shell semantics: path element "" means "." @@ -217,5 +217,5 @@ func LookPath(file string) (string, os.Error) { return dir + "/" + file, nil } } - return "", os.ENOENT; + return "", os.ENOENT } |