I'm trying to write a simple script that read from standard input, using
; character as delimiter to terminate the input line and that allows user to edit line.
Here is my test script:
#!/bin/bash while true; do read -e -d ";" -t 180 -p "><> " srcCommand if [ $? != 0 ]; then echo "end;" echo "" exit 0 fi case "$srcCommand" in startApp) echo "startApp command";; stopApp) echo "stopApp command";; end) echo "" exit 0 ;; *) echo "unknown command";; esac done
This works but doesn't print the delimiter ';' char:
# bash test.sh ><> startApp startApp command ><> stopApp stopApp command ><> end
If I remove -e option it prints out
; but user can't correct his mistake using backspace character and echoed strings are just right after the delimiter:
# bash test.sh ><> startApp;startApp command ><> stopApp;stopApp command ><> end;
How can I print out the delimiter character and allow user to edit line while reading standard input?
This is the expected behavior:
# bash test.sh ><> startApp; startApp command ><> stopApp; stopApp command ><> end;