screencast
screencast copied to clipboard
dash shell chokes on quoted variables in arithmetic expressions
When using dash to run screencast it terminated with this error message:
dash /usr/local/bin/screencast -s 1280x720 -p 200,234 sc2.mp4
screencast v1.6.0 - Copyright (c) 2015-2023 Daniel Bermond
Command line interface to record a X11 desktop
https://github.com/dbermond/screencast/
[ screencast ] initializing
/usr/local/bin/screencast: 3215: arithmetic expression: expecting primary: ""1280" % 8"
The error is caused by this code (line 66 in screen.sh)
check_dimension() {
# the dimension will be a multiple of 8 if the remainder is 0
[ "$(("$1" % 8))" = '0' ]
}
The cause is that "$1" is quoted. When removing the quotes, dash processes this fine.
[ "$(("$1" % 8))" = '0' ]
I would say that quotes are not needed. If the value of parameter is empty or contains spaces the result should be invalid anyway.
Debian uses /bin/sh as a symbolic link to dash. So when calling screencast as executable it terminates with this error. The easiest solution for Debian users is to call screencast explicitely with bash.
Or, as I did, replace the symbolic link with a pointer to bash. I cannot imagine when I would use dash instead.
jlinkels