Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dash shell chokes on quoted variables in arithmetic expressions #20

Open
jlinkels opened this issue Jan 3, 2023 · 0 comments
Open

dash shell chokes on quoted variables in arithmetic expressions #20

jlinkels opened this issue Jan 3, 2023 · 0 comments

Comments

@jlinkels
Copy link

jlinkels commented Jan 3, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant