|
|
|
|
|
by icefox
3882 days ago
|
|
The bash example should have set -e or #!/bin/bash -e so that it will exit on error. That or the rest of the languages also shouldn't bother to check for errors. Also rather than invoking another shell use let and do let STATE=1-$STATE just like all the other programs. And why does bash need to have comments. Maybe it was a subtle joke that C doesn't get comments, but bash does :D in which case well played. #!/bin/bash -e
STATE=1
while : do
echo $STATE > /sys/class/leds/beaglebone\:green\:usr0/brightness
let STATE=1-$STATE
sleep 2
done
While all of the programs can be made smaller in size the bash script is probably the default way that the script would be tossed together. Bash has a ton of problems, but sadly between it and the standard unix commands you can get the job done too quickly and easily. |
|
That wasn't a subshell - $(( )) is Arithmetic Expansion. (you may be thinking of $( ) for Command Substitution)
Now, using the result of a boolean is a bit strange; I would have used your math with the modern expansion style: