Skip to content

Commit 159044c

Browse files
committed
Fix Shell script examples to use double brackets for safer variable comparison
1 parent 5738a15 commit 159044c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/cs-basics/operating-system/shell-intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ echo "Total value : $val"
286286
#!/bin/bash
287287
score=90;
288288
maxscore=100;
289-
if [ $score -eq $maxscore ]
289+
if [[ $score -eq $maxscore ]]
290290
then
291291
echo "A"
292292
else
@@ -329,7 +329,7 @@ echo $a;
329329
#!/bin/bash
330330
a="abc";
331331
b="efg";
332-
if [ $a = $b ]
332+
if [[ $a = $b ]]
333333
then
334334
echo "a 等于 b"
335335
else
@@ -359,10 +359,10 @@ a 不等于 b
359359
#!/bin/bash
360360
a=3;
361361
b=9;
362-
if [ $a -eq $b ]
362+
if [[ $a -eq $b ]]
363363
then
364364
echo "a 等于 b"
365-
elif [ $a -gt $b ]
365+
elif [[ $a -gt $b ]]
366366
then
367367
echo "a 大于 b"
368368
else

0 commit comments

Comments
 (0)