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.
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: