Skip to content

Commit 206ac44

Browse files
use case instead of if statement
1 parent cfc47ec commit 206ac44

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

β€Žgenerator.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ table=table.txt
55

66
for shell in sh bash fish ksh
77
do
8-
if [ "$shell" = "bash" ]; then
8+
case $shell in
9+
"bash")
910
fn='function '
1011
dot='.'
1112
echo='echo'
@@ -14,7 +15,8 @@ do
1415
endIf='fi'
1516
brackets=
1617
para='@'
17-
elif [ "$shell" = "ksh" ];then
18+
;;
19+
"ksh")
1820
fn='function '
1921
dot=
2022
echo='/bin/echo'
@@ -23,7 +25,8 @@ do
2325
endIf='fi'
2426
brackets=
2527
para='@'
26-
elif [ "$shell" = "fish" ];then
28+
;;
29+
"fish")
2730
fn='function '
2831
dot='.'
2932
echo='echo'
@@ -32,7 +35,8 @@ do
3235
endIf='end'
3336
brackets=
3437
para='argv'
35-
else
38+
;;
39+
*)
3640
fn=
3741
dot=
3842
echo='/bin/echo'
@@ -41,7 +45,7 @@ do
4145
endIf='fi'
4246
brackets='()'
4347
para='@'
44-
fi
48+
esac
4549

4650
newDist="$dist.$shell"
4751
echo "#!/usr/bin/env $shell" > $newDist

0 commit comments

Comments
Β (0)