Score:0

bash: set command: enable the options by overwriting the previous ones

it flag

Pretending that the output of $- is this:

hims

If I add options with the set command:

set -B

the output of $- becomes this:

himBs

but I would like it to become this:

iBs

So that it overwrites the previous options.

Score:1
tm flag

You can create the following function to do what you want:

myset () {
    options=$-
    options=${options//[is]}  # remove "i" and "s"
    set +"$options"
    set -"$1"
}

And call

myset B
it flag
Yes, ok, after I thought about it but the fact remains that in addition to the options `i` and `s` there are others not to be removed (because it would give an error), for example one of them is option `c`.
it flag
The ideal choice would be to tell the `set` command to ignore the nonexistent options, while working on the others anyway. Is there a switch to do this?
tm flag
No, there's no such option.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.