Bash READ prompt being able to tab and interact like a SHELL prompt

Viewed 61

I am developing a simple script which interactively asks the user folder paths to analyze.

read -p 'Provide the folder to analyze: ' newFolderToAnalyze

The problem or misbehaviour is that read -p '...' can't interact with the user shell environment, I can't just write /home/ and then tab to autocomplete,

Is there any way using shell scripts to ask for something to the users but still using all the functions the shell prompt has to offer?

It seems like when the scripts enters that read -p '..' line, all the powerful functions from the interpreter vanishes.

1 Answers

just use read -e -p 'Provide the folder to analyze: ' newFolderToAnalyze

this enables readline, since read is shell builtin use help read to check its manpage :)

Related