============ Ask Question ============ .. default-domain:: bash .. file:: ask_question Bash CLI version of :func:`ask_question` :Arguments: ``$1`` - The question [``$2``] - Default answer (when user presses enter only) :Output: Returns ``0`` for yes, ``1`` for no .. seealso:: :func:`ask_question` .. function:: ask_question Pretty version of ask Y/N question with optional default value :Arguments: ``$1`` - The question ``$2`` - Variable to store answer in: 1 for yes, 0 for no [``$3``] - Default answer (when user presses enter only) [``!2``] - If the value of the variables named by $2 is set, then this will override the answer for the question asked. This is a good way to automate calling a script/function that contains ask_question and skip prompting the user for an answer. :Output: Stores ``1`` for yes, and ``0`` for no in the variable specified by ``$2`` .. rubric:: Example .. code-block:: bash source "${VSI_COMMON_DIR}/linux/ask_question" ask_question "Continue?" y ask_question "Would you like to play a game?" play y ans=y ask_question "This question will not wait, but answer yes for you." ans n .. note:: Only the first letter of the response matters. Accepted values are yYnN (and blank if a default answer is given), else the question is asked again until an appropriate response is given. .. warning:: If the same variable is used to store the answer for multiple :func:`ask_question` calls, then the result from the first call will act as the override. Luckily it is a ``1`` or ``0``, so it won't give a valid answer. But the best practice is to use different variable names for consecutive ask_question's