"Build your own shell" - Stage #IP1 (golang): Expected outpout to match

I’m stuck on Stage #IP1.

I’ve managed to run the external command but the outpout does not match the expected outpout. I’ve looked at some code examples and even though I have the same implementation as them I can’t seem to pass the test.

Here are my logs:

[tester::#IP1] Running tests for Stage #IP1 (Run a program)
[tester::#IP1] Running ./your_shell.sh
[your-program] $ 
[tester::#IP1] > my_exe James
[your-program] Hello james! The secret code is 401453.
[tester::#IP1] Expected output to match "Hello James! The secret code is 401453.\n", got "Hello james! The secret code is 401453.\r\n"
[tester::#IP1] condition not met
[tester::#IP1] Test failed

And here’s a snippet of my code:

func startRepl() error {
	commands := getCommands()

	reader := bufio.NewScanner(os.Stdin)
	printPrompt()

	for reader.Scan() {
		text := cleanInput(reader.Text())
		spltText := strings.Split(text, " ")
		if command, exists := commands[spltText[0]]; exists {
			err := command.Callback(spltText[1:]...)
			if err != nil {
				return fmt.Errorf("error running command err: %w", err)
			}
		} else {
			if file, err := handleEnviromentVariablePaths(spltText[0]); err == nil {
				cmd := exec.Command(file, spltText[1:]...)
				cmd.Stderr = os.Stderr
				cmd.Stdout = os.Stdout

				if err := cmd.Run(); err != nil {
					return fmt.Errorf("error running external command err: %w", err)
				}
			} else {
				fmt.Printf("%s: command not found\n", spltText[0])
			}
		}
	}

	return nil
}

You are passing james instead of James so somewhere in your code you convert the intput to lowercase, maybe in cleanInput?

You are completely right about that. I didn’t even see that, I thought that the error was thrown because of the \r\n instead of \n.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.