Open hackthedev opened 2 years ago
That usually means you have a stray (or missing) "
somewhere.
if you (space or tab) indent your script, it will be easier to tell where your if .. then .. elif .. fi
start and end.
is this line 63? new_rotate_value=$[(($default_value+$1)%360)/90]
.
for text value compare [ $output_type = "gpio" ]
is not the same as [ "$output_type" = "gpio" ]
- when doing text compare, always stick your variables inside double quotes ("
) otherwise you will have problems with this (if variable has spaces, tabs or newlines).
for numerical value compare V=""; [ $V -eq 0 ]
is not the same as V=0; [ $V -eq 0 ]
, but that is the same as V="0"; [ $V -eq 0 ]
.
with sed
if you are inserting variables at runtime then do it differently, eg:
sed -i -e $line "s/$str/display_rotate=\"$new_rotate_value\"/g"
NOTE: even though all sed
examples show use of quotes of some kind (usually '
) you dont need them, you just have to supply a solid string value to sed
(ie no white-space) eg: sed -i -e $line s/rotate=$old/rotate=$new/g
will work fine (its only with the explicit regex selections that things start to get complicated).
FWIW: inline $(commands)
are faster than ``commands``
because the current shell does not open a new shell to process commands
(and you can nest them inside each other as well).
Hi my rotate.sh file looks like the following:
Im getting the error like the following