why using space it return false?

49 views Asked by At

I have to solve this problem. I'm new in bash scripting.

This is my problem:

#!/bin/bash

echo "In quale mese e anno è nato Albert Einstein?"
read risposta1 risposta2

shopt -s nocasematch
until [[ $risposta1 = marzo ]] || [[ $risposta2 = 1879 ]]
do
    echo "Risposta errata, riprova!"
    read risposta1 risposta2
done

echo "Risposta corretta"

Then if answering I type space 1879 the result is incorrect. This exercise needs to be correct if I choose marzo or 1879.

This is the error:

obnoxious image of text

I also try to using "" but i receive the error command not found if I type for example g 47

1

There are 1 answers

6
Jetchisel On

Maybe something like this.

#!/usr/bin/env bash

shopt -s nocasematch
until [[ "${risposta[0]}" = @(marzo|1879) || "${riposta[1]}" = @(marzo|1879) ]]; do
  echo "Risposta errata, riprova!"
  read -ra risposta
done