Colin Halter
Colin Halter

Reputation: 11

Read command throws bad variable name error in script, but not from terminal

I'm trying to curl the script:

#!/bin/ash
echo "Text Prompt: "
read REPLY
echo $REPLY

However, I get this output:

Text Prompt:
: bad variable name

When I run the command from the terminal, it works fine. I've also tried the following with similar results:

#!/bin/ash
read -p "Text Prompt: " vName=$REPLY
echo vName

#!/bin/ash
read -p "Text Prompt: " && vName=$REPLY
echo vName

Upvotes: 1

Views: 1689

Answers (1)

Colin Halter
Colin Halter

Reputation: 11

I was editing in notepad++, which adds windows-specific newline characters onto the end of the line. Tried doing it in sublime and it worked immediately.

Upvotes: 0

Related Questions