Re: [PATCH] make 'set +o' useful and POSIX compatible
Hi Martijn, >>> We're at R56 now but nothing seems to have changed here. Status? >> >> It’s on the TODO. > > Here's another attempt at a patch. Note that this version checks for OFF(i) != > OF_CMDLINE to exclude immutable command line-only options (interactive, login, > restricted, stdin). I’ve experimentally (reads: may change, but as it isn’t a regression, it can be included already anyway) solved it thusly: The current state of the options, with some normalisation¹, is saved away at shell startup. “set +o” then outputs a command² beginning with “-o .reset” which restores it, followed by ±o as needed. ① FPOSIX, FSH, and those they clear as side effect (FBRACEEXPAND and UTFMODE) are zero’d, so these will be always output if set ② FPOSIX and FSH first, all others later, due to these side effects Note that the “-o .reset” behaviour is not consistent across shell invocations (interactive vs. mksh -c differ e.g. in interactive, monitor, stdin, trackall), but, as the command following it will only show differences from default, I think it’s good enough. Please find this in R59b (which also fixes your regression) for your pleasure (and finding new bugs…). bye, //mirabilos -- Support mksh as /bin/sh and RoQA dash NOW! ‣ src:bash (389 (415) bugs: 1 RC, 264 (283) I, 124 (131) M, 0 F) ‣ src:dash (89 (104) bugs: 0 RC, 47 (51) I, 42 (53) M, 0 F) ‣ src:mksh (0 bugs: 0 RC, 0 I, 0 M, 0 F) dash has two RC bugs they just closed because they don’t care about quality…
Re: [PATCH] make 'set +o' useful and POSIX compatible
Martijn Dekker dixit: >> I’ll put the issue on my TODO only, for now, but thanks anyway. > >We're at R56 now but nothing seems to have changed here. Status? It’s on the TODO. bye, //mirabilos -- 11:56⎜«liwakura:#!/bin/mksh» also, i wanted to add mksh to my own distro │ i was disappointed that there is no makefile │ but somehow the Build.sh is the least painful built system i've ever seen │ honours CC, {CPP,C,LD}FLAGS properly │ looks cleary like done by someone who knows what they are doing
Re: [PATCH] make 'set +o' useful and POSIX compatible
Martijn Dekker schreef op 27-02-16 om 04:44: > That means it should be possible to do > > save_options=$(set +o) > > then change some options, then later restore the shell options with > > eval "$save_options" Hmm. "-o interactive" is killing that with an "interactive: bad option" error. Yet, misc.c contains this bit of code: if ((i != (size_t)-1) && (set ? 1U : 0U) == Flag(i)) /* * Don't check the context if the flag * isn't changing - makes "set -o interactive" * work if you're already interactive. Needed * if the output of "set +o" is to be used. */ ; And if I manually experiment with "set -o", then it works as the comment above says. But there must be some kind of bug in there because evalling the output of the patched "set +o" outputs the "interactive: bad option" error. $ eval "$(set +o)" ../build/mksh: set: interactive: bad option Ah ha! I see now: the 'interactive' option is turned off in subshells (including command substitutions), so the output of set +o is not the same as that of (set +o) Hmm. And the "monitor" (job control) option is also turned off in subshells. This clearly needs more work. Perhaps those two options should simply be blacklisted from "set +o" output? Thoughts? - M.