Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shopt -p and -o compatibility with bash #2013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

momiji
Copy link
Collaborator

@momiji momiji commented Jun 28, 2024

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

In hope this is now the correct behavior.

@andychu
Copy link
Contributor

andychu commented Jun 29, 2024

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
Copy link
Collaborator Author

momiji commented Jun 29, 2024

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
Copy link
Contributor

andychu commented Jul 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants