Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • thanks, your code works nicely. so to get a full list of all options, you would have to use both set +o and shopt ? (as to shoptable being a word, settable is used in the man page, so shoptable works for me) Commented Jun 17, 2015 at 7:27
  • @user4668401 - I think that will do it. Commented Jun 17, 2015 at 7:37
  • 3
    TL;DR, but +1000 for the 3 lines solution to change an option and put it back 'as it was'. Thats exactly what one needs when creating scripts or copy/pastable instructions. Commented Aug 10, 2017 at 10:09
  • 3
    @mikeserv Seems that -p option needs to be added when saving state to include shoptions, i.e. state=$(set +o;shopt -p) Commented Feb 9, 2018 at 16:58
  • 1
    Wouldn't this work just as well for capturing the current set options? set -f -- -$-? Commented Feb 1, 2023 at 5:08