pkg/tool/exec: use os.Stdin on null only

Change-Id: I561a5558a4c7651a1b69a94596f52fa1586abad9
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4601
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/testdata/script/cmd_stdin.txt b/cmd/cue/cmd/testdata/script/cmd_stdin.txt
index a397a47..c0b28d9 100644
--- a/cmd/cue/cmd/testdata/script/cmd_stdin.txt
+++ b/cmd/cue/cmd/testdata/script/cmd_stdin.txt
@@ -5,7 +5,6 @@
 
 -- expect-stdout --
 Hello World!
-
 -- stdin.txt --
 Hello World!
 -- hello_tool.cue --
@@ -15,13 +14,13 @@
     echo: {
         kind:   "exec"
         cmd:    "cat"
-        stdin: string
         stdout: string
     }
 
-    task: display: {
-        kind: "print"
-        text: echo.stdout
+    pass: {
+        kind:   "exec"
+        cmd:    "cat"
+        stdin:  echo.stdout
     }
 }
 -- cue.mod --
diff --git a/pkg/tool/exec/doc.go b/pkg/tool/exec/doc.go
index ff150d0..7a8eb45 100644
--- a/pkg/tool/exec/doc.go
+++ b/pkg/tool/exec/doc.go
@@ -26,9 +26,9 @@
 //     	// stderr is like stdout, but for errors.
 //     	stderr: *null | string | bytes
 //
-//     	// stdin specifies the input for the process. If stdin is not a concrete
-//     	// value, it will capture the input from stdin. Otherwise, if it is null,
-//     	// there is no input. Otherwise it will read from the given value.
+//     	// stdin specifies the input for the process. If stdin is null, the stdin
+//     	// of the current process is redirected to this command (the default).
+//     	// If it is of typ bytes or string, that input will be used instead.
 //     	stdin: *null | string | bytes
 //
 //     	// success is set to true when the process terminates with with a zero exit
diff --git a/pkg/tool/exec/exec.cue b/pkg/tool/exec/exec.cue
index be7843e..f827fd6 100644
--- a/pkg/tool/exec/exec.cue
+++ b/pkg/tool/exec/exec.cue
@@ -36,9 +36,9 @@
 	// stderr is like stdout, but for errors.
 	stderr: *null | string | bytes
 
-	// stdin specifies the input for the process. If stdin is not a concrete
-	// value, it will capture the input from stdin. Otherwise, if it is null,
-	// there is no input. Otherwise it will read from the given value.
+	// stdin specifies the input for the process. If stdin is null, the stdin
+	// of the current process is redirected to this command (the default).
+	// If it is of typ bytes or string, that input will be used instead.
 	stdin: *null | string | bytes
 
 	// success is set to true when the process terminates with with a zero exit
diff --git a/pkg/tool/exec/exec.go b/pkg/tool/exec/exec.go
index 32f8d01..0846b16 100644
--- a/pkg/tool/exec/exec.go
+++ b/pkg/tool/exec/exec.go
@@ -97,12 +97,10 @@
 		return c, true
 	}
 
-	if v, ok := stream("stdin"); ok {
-		if !v.IsConcrete() {
-			cmd.Stdin = ctx.Stdin
-		} else if cmd.Stdin, err = v.Reader(); err != nil {
-			return nil, fmt.Errorf("cue: %v", err)
-		}
+	if v, ok := stream("stdin"); !ok {
+		cmd.Stdin = ctx.Stdin
+	} else if cmd.Stdin, err = v.Reader(); err != nil {
+		return nil, fmt.Errorf("cue: %v", err)
 	}
 	_, captureOut := stream("stdout")
 	if !captureOut {