qcm

Faire des qcm simplement - retour accueil

git clone git://bebou.netlib.re/qcm
Log | Files | Refs | README |

commit 8e85ee78b1db21c5d0f321f50e0f3298731673e8
parent 12e512a0187a6f972ac86bf5d0cef60abe40f5db
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 11 Dec 2024 16:15:17 +0100

Syntaxe [ -a ] vers [] && [], + mieux

Voir dans le manuel posix de test

       The XSI extensions specifying the -a and -o binary primaries and the '(' and ')' op‐
       erators  have  been marked obsolescent. (Many expressions using them are ambiguously
       defined by the grammar depending  on  the  specific  expressions  being  evaluated.)
       Scripts  using  these expressions should be converted to the forms given below. Even
       though many implementations  will  continue  to  support  these  obsolescent  forms,
       scripts should be extremely careful when dealing with user-supplied input that could
       be confused with these and other primaries and operators. Unless the application de‐
       veloper knows all the cases that produce input to the script, invocations like:

           test "$1" -a "$2"

       should be written as:

           test "$1" && test "$2"

       to avoid problems if a user supplied values such as $1 set to '!'  and $2 set to the
       null string. That is, in cases where maximal portability is of concern, replace:

           test expr1 -a expr2

       with:

           test expr1 && test expr2

       and replace:

           test expr1 -o expr2

       with:

           test expr1 || test expr2

       but note that, in test, -a has higher precedence than -o while "&&"  and  "||"  have
       equal precedence in the shell.

Ici il se trouve que l'on ne sait pas forcément ce qu'il y a dans type.
Donc c'est mieux. De toute façon ça ne mange pas de pain.

Diffstat:
Mqcm.sh | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qcm.sh b/qcm.sh @@ -62,7 +62,7 @@ calcandshow() { if [ -n "$hide" ];then groupedanswers= else - if [ "$type" != "ouverte" -a "$type" != "regex" ];then + if [ "$type" != "ouverte" ] && [ "$type" != "regex" ];then sortanswers='while read line;do echo "$line" | grep -o . | sort -u | paste -s -d "\0" -;done' else sortanswers='cat' fi