If you run sh
and then try that command, you get:
read: 1: Illegal option -d
If you do it while still in bash
, it works fine.
I therefore deduce that your script is not running under bash
.
Make sure that your script begins with the line:
#!/usr/bin/env bash
(or equivalent) so that the correct shell is running the script.
Alternatively, if you cannot do that (because the script is not a bash
one), just be aware that -d
is a bash
feature and may not be available in other shells. In that case, you will need to find another way.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…