Read: line 6: illegal option -e

For some reason read -e isn't working in my script. I need a directory as input from a user and I'd like for them to be able to use tab complete which is why I'm using -e. When the script is run, I get:

read: line 6: illegal option -e

In order to just figure out what is going on with the -e option I made a small test script that gives the error:

#!/bin/bash

set -e

echo "This is a test."
read -e dir

echo $dir

Anyone know why I would be getting the illegal option -e?

or is there another way to get tab complete for the user input?

Specifically, which operating system are you using? Exactly how are you invoking the script? What is the mode (file permissions) of the script file?

Regards and welcome to the forum,
Alister

when I run /proc/version I get:

Linux version 2.6.31.8 (@) (gcc version 4.3.2 (sdk3.3-ct-ng-1.4.1) ) #1 Tue Jul 24 18:11:21 PDT 2012

I've done a chmod 777 and a chmod +x to the file.

and to run it I've tried:
./test.sh
sh test.sh
bash test.sh

all resulting in the same error.

---------- Post updated at 05:30 PM ---------- Previous update was at 11:59 AM ----------

Nobody has any ideas?

Is there another way to get tab complete to work with the user input without "-e"?

Can you change set -e on line 3 to set -x and post the output.

You may have an old version of bash which doesn't support -e.

And, no.