My goal is to add a path to user PATH environment variable during installation process but I want to request his permission first.
A workaround would be to set an option for cmake command line but it’s not user friendly as he must allow (or disallow) at configuration step for the manipulation, which is disconnect from installation time.
#/usr/bin/env bash
while true; do
read -p "Do you want to go on? (yn) " yn
case $yn in
[yY] ) echo "go on";
exit 0;;
[nN] ) echo "stop";
exit 1;;
* ) echo "invalid response";;
esac
done
read prompt is not displayed and echo command are buffered into FOO but not displayed.
besides in this case all echo are buffered, whereas I would be interested only in the last echo (for instance: “stop” instead of “invalid response invalid response invalid response invalid response stop”)
I don’t know that stdin is forwarded properly for this kind of stuff. I have no idea what this means for cmake-gui or ccmake (in a full CMake run). Script mode might be able to support it, but it sounds new to me.
Try this keyboard input function, it works with bash, sh, powershell and cmd.
When enter is pressed, a variable containing the keyboard input string is returned.
Thanks for proposing a solution. I actually already implemented a workaround based on a “per shell” basis, with a fallback, which is quite unsatisfactory. I didn’t reported it because I expected some more general solution. You’re covering two cases I didn’t need so far so I’m keeping your proposal in some corner if they become relevant.
btw my approach is slightly different, instead of giving the command through cmake, I’m calling a sub-script in the given shell langage. I don’t know the pro and cons of both ways to go.