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

using shift in getopts triggers an assert #177

Open
Earnestly opened this issue Jan 29, 2021 · 0 comments
Open

using shift in getopts triggers an assert #177

Earnestly opened this issue Jan 29, 2021 · 0 comments

Comments

@Earnestly
Copy link

I have encountered a few issues when using getopts while testing a potential bug in dash and discovered a segmentation fault condition in mrsh doing the following:

#!/bin/sh --

while getopts :a: arg; do
    case $arg in
        a)
            set -- "$@" attr="$OPTARG"
            shift 2
    esac
done

printf '[%s]' "$@"
mrsh -x example.sh -a foo -a bar
+ getopts :a: arg
+ set -- -a foo -a bar attr=foo
+ shift 2
+ getopts :a: arg
mrsh: ../getopt.c:13: _mrsh_getopt: Assertion `argv[argc] == NULL' failed.
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