0

In bash, it is possible to check for active option with -o: such as [ -o nounset ] && echo "Option -u active"

But (d)ash (the shell included in busybox) does not seem to recognize -o in tests.

How to test for options in ash/dash? Or, maybe, is there other hack specific to busybox?

0

Answer:

"set -o" prints the list of all known options, with their states as "on" or "off".

"set +o" prints the same, but instead of "option on/off the output format is "set +o option" or "set -o option".

Grep that.

Thanks everyone who wanted to help ;)

0

Another answer: (Thanks to folks on the busybox mailing list)

Special variable $- expands to string of all active option letters. This works on ash/dash and bash as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.