The Book: Chapter 12.5, a task has you set the boolean in terminal

In the book it talks about using powershell to set CASE_INSENSITIVE=1 to get the output:
"Are you nobody, too?
How dreary to be somebody!
To tell your name the livelong day
To an admiring bog!"

What would the command be for linux terminal?

I have tried

$Env:CASE_INSENSITIVE=1; cargo run to poem.txt

But that only outputs two lines:

"Are you nobody, too?
How dreary to be somebody!"

I'm not sure what term to look up, or I would have.

Thank you.

On linux, this typically looks like

CASE_INSENSITIVE=1 cargo run to poem.txt

which is also what's used in the book, a few lines further down.

Unlike the powershell command, this way the environment variable will also only be set for this single command, and not persist through the remainder of the session.

1 Like

ok, it still isn't working. If you're sure that should work, then there is something else wrong, and I will investigate.

Thank you.

First thing to make sure is that you didn't misspell the name of the environment variable anywhere. You can also add

    for v in std::env::vars() {
        println!("{:?}", v);

into your program at some point to print out all avaliable environment vars and check whether CASE_INSENSITIVE is in there or missing.

And you could add dbg!(&case_sensitive); after the let case_sensitive = ... line to double-check whether the environment variable isn't recognized, or something else is wrong in the program logic.

1 Like

Very cool.
Yes, typo... got it working. Thanks.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.