<commit_before>// Copyright 2012 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
sh reads in a line at a time and runs it. 
prompt is '% '
*/

package main

import (
	"os/exec"
	"fmt"
	"os"
	"strings"
	"bufio"
)

func main() {
	if len(os.Args) != 1 {
		fmt.Println("no scripts/args yet")
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	fmt.Printf("%% ")
	for scanner.Scan() {
		cmd := scanner.Text()
		argv := strings.Split(cmd, " ")
		e := os.Environ()
		e = append(e, "GOROOT=/go")
		e = append(e, "GOPATH=/")
		e = append(e, "GOBIN=/bin")
		run := exec.Command(argv[0], argv[1:]...)
		run.Env = e
		out, err := run.CombinedOutput()
		if err != nil {
			fmt.Println(err)
		}
		fmt.Printf("%s", out)
		fmt.Printf("%% ")
	}
}
<commit_msg>Print the path when things don't work.<commit_after>// Copyright 2012 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*
sh reads in a line at a time and runs it. 
prompt is '% '
*/

package main

import (
	"os/exec"
	"fmt"
	"os"
	"strings"
	"bufio"
)

func main() {
	if len(os.Args) != 1 {
		fmt.Println("no scripts/args yet")
		os.Exit(1)
	}

	scanner := bufio.NewScanner(os.Stdin)
	fmt.Printf("%% ")
	for scanner.Scan() {
		cmd := scanner.Text()
		argv := strings.Split(cmd, " ")
		e := os.Environ()
		e = append(e, "GOROOT=/go")
		e = append(e, "GOPATH=/")
		e = append(e, "GOBIN=/bin")
		run := exec.Command(argv[0], argv[1:]...)
		run.Env = e
		out, err := run.CombinedOutput()
		if err != nil {
			fmt.Printf("%v: Path %v\n", err, os.Getenv("PATH"))
		}
		fmt.Printf("%s", out)
		fmt.Printf("%% ")
	}
}

{'fraction_non_alphanumeric': 0.18757126567844926, 'fraction_numerical': 0.009122006841505131, 'mean_word_length': 3.006849315068493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7408706', 'n_tokens_mistral': 755, 'n_tokens_neox': 700, 'n_words': 196}