oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.85k stars 159 forks source link

shopt -p and -o compatibility with bash #2013

Open momiji opened 5 months ago

momiji commented 5 months ago

-o changes which settings are displayed -p display commands instead of a table

In hope this is now the correct behavior.

andychu commented 5 months ago

Hm are you relying on this behavior anywhere?

I agree that we are little incompatible with other shells, because we don't print this format

But we DO print an unambiguous format that you can parse

andy@hoover:~/git/oilshell/oil$ bash -c 'set -o' |head
allexport       off
braceexpand     on
emacs           off
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      off
history         off
ignoreeof       off

andy@hoover:~/git/oilshell/oil$ zsh -c 'set -o' |head
noaliases             off
aliasfuncdef          off
allexport             off
noalwayslastprompt    off
alwaystoend           off
appendcreate          off
noappendhistory       off
autocd                off
autocontinue          off
noautolist            off

andy@hoover:~/git/oilshell/oil$ mksh -c 'set -o' |head
Current option settings
allexport      off                                                                         markdirs       off                                                                         privileged     off
asis           off                                                                         monitor        off                                                                         restricted     off
bgnice         off                                                                         noclobber      off                                                                         sh             off
momiji commented 5 months ago

Yes I agree, it just to mimic the behavior of other for the table display. The objective here is to get closer to bash for being a "near bash replacement".

As mentioned, all shells did not print the same, bash using space+tab while the others don't.

It doesn't really matter as most of the time it's just for printing, and in scripts most probably used with awk or grep off$. And regarding the idea to display both shopt and set options, maybe we can add a -a for all ;)

andychu commented 4 months ago

Well I'm suggesting we do something that's better, not just what bash is, e.g. in shopt --tsv or something

I don't see any evidence people rely on the bash-like format -- because if you parse it, you would probably use the other format (?)


I guess I like that we have 1 format now -- that leaves room for 1 more

But I don't want to end up with 3 formats, since it's a maintenance hazard

Let's defer this until we sort out the other changes