diff options
author | Steven <steven.vasilogianis@gmail.com> | 2021-11-16 15:59:59 -0500 |
---|---|---|
committer | Steven <steven.vasilogianis@gmail.com> | 2021-11-16 15:59:59 -0500 |
commit | 2ad4581407de20be160a078f4722b42199c0273e (patch) | |
tree | 1c7127b5fa23a887f1866281d1ce5c4ca569bc34 | |
parent | 5da6c52872dbc9b66b804774869808f1aa663abb (diff) |
switch instead of if
-rwxr-xr-x | shopenscad.sh | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/shopenscad.sh b/shopenscad.sh index be1a9ec..3c71b1f 100755 --- a/shopenscad.sh +++ b/shopenscad.sh | |||
@@ -90,7 +90,6 @@ parse_options() | |||
90 | 90 | ||
91 | SCAD_FILE="$*"; | 91 | SCAD_FILE="$*"; |
92 | [ -f "$SCAD_FILE" ] || die "$0: Needs an input scad file" | 92 | [ -f "$SCAD_FILE" ] || die "$0: Needs an input scad file" |
93 | |||
94 | } | 93 | } |
95 | 94 | ||
96 | die() { printf 'Error: %s\n' "$*" >&2; exit 1; } | 95 | die() { printf 'Error: %s\n' "$*" >&2; exit 1; } |
@@ -185,15 +184,12 @@ main() | |||
185 | 184 | ||
186 | if [ "$PRINT_VARS" ]; then | 185 | if [ "$PRINT_VARS" ]; then |
187 | for k in "${scad_var_order[@]}"; do | 186 | for k in "${scad_var_order[@]}"; do |
188 | # if the value is an OpenSCAD string, it needs to be wrapped in | 187 | # Make sure quotes surround openscad strings |
189 | # quotes | 188 | case "${SCAD[$k]:0:1}" in |
190 | if [ '"' == "${SCAD[$k]:0:1}" ]; then | 189 | \" ) line="${k}='${SCAD[$k]}'";; |
191 | line="${k}='${SCAD[$k]}'" | 190 | \' ) line=${k}="\"${SCAD[$k]}\"";; |
192 | elif [ "'" == "${SCAD[$k]:0:1}" ]; then | 191 | * ) line="${k}=${SCAD[$k]}";; |
193 | line=${k}="\"${SCAD[$k]}\"" | 192 | esac |
194 | else | ||
195 | line="${k}=${SCAD[$k]}" | ||
196 | fi | ||
197 | echo $line | 193 | echo $line |
198 | done | 194 | done |
199 | exit | 195 | exit |