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 block syntax should accept oil:all #1099

Closed
glyh opened this issue Mar 6, 2022 · 10 comments
Closed

shopt block syntax should accept oil:all #1099

glyh opened this issue Mar 6, 2022 · 10 comments

Comments

@glyh
Copy link
Collaborator

glyh commented Mar 6, 2022

As title. It would be great if there's some kind of mechanics to make them work together. e.g. through some module mechanics. Therefore user can use oil in their own scripting environment, yet depending on osh scripts from legacy environment.

@glyh
Copy link
Collaborator Author

glyh commented Mar 6, 2022

I think this can be easily fixed by adding some options to the source command.

@andychu
Copy link
Contributor

andychu commented Mar 7, 2022

I don't recommend it, but you can do this already with something like

shopt --unset oil:all {
  source foo.sh
}

or vice versa

shopt --set  oil:all {
  source foo.oil
}

bin/osh and bin/oil are just aliases for a bunch of global shell options.

What I'd recommend instead is to simply invoke one script from the other. You can invoke an OSH script from and Oil script and vice versa. Using the "$0 dispatch pattern" would probably help.

Some more info: https://github.com/oilshell/oil/wiki/OSH-versus-Oil

@glyh
Copy link
Collaborator Author

glyh commented Mar 7, 2022

This does not seem to be working, in my oilrc:

shopt --unset oil:all {
  source ./oshrc
}

I got:

  shopt --unset oil:all {
  ^~~~~
'/home/lyh/.config/oil/oilrc':1: 'shopt' got invalid option 'oil:all'
  shopt --unset oil:all {
  ^~~~~
'/home/lyh/.config/oil/oilrc':1: errexit PID 13618: Command failed with status 2

Version:

Oil version 0.9.8
Release Date: 2022-02-19 22:18:32+00:00
Arch: x86_64
OS: Linux
Platform: #1 ZEN SMP PREEMPT Wed, 02 Mar 2022 12:22:53 +0000
Compiler: GCC 11.2.0
Interpreter: OVM
Interpreter version: 2.7.13
Bytecode: bytecode-opy.zip

@andychu
Copy link
Contributor

andychu commented Mar 7, 2022

Hm that is odd, it does seem like there is an issue using the block syntax

Both of these don't cause an error

osh -c 'shopt -s oil:all`
oil -c 'shopt -s oil:all`

But adding the block introduces an error. I will look into it

@andychu andychu changed the title Osh Oil Interop shopt block syntax doesn't accept oil:all Mar 7, 2022
@andychu
Copy link
Contributor

andychu commented Mar 7, 2022

Ah OK now I see why ... this is more like an oversight than a bug

I think that should work so you can interoperate between the two

@glyh
Copy link
Collaborator Author

glyh commented Mar 7, 2022

How is this implemented? Is this hard coded to consume a block after it, or blocks are a basic type of oil that can be passed around in oil? I personally prefer the second way.

@andychu
Copy link
Contributor

andychu commented Mar 7, 2022

It's designed as a first class type, and should be part of the value_t enum in core/runtime.asdl

However it's not fully exposed to users right now. #1025 is part of it

@andychu
Copy link
Contributor

andychu commented May 26, 2022

This came up here:

Because config file evaluation need an implicit shopt --set oil:all

andychu pushed a commit that referenced this issue May 26, 2022
That is, support an option GROUP with the block syntax.

This is #1099.

Also fix a BUG where 'shopt -p' didn't respect the option stack.
@andychu
Copy link
Contributor

andychu commented May 26, 2022

OK this will be out with the next release!

@andychu andychu changed the title shopt block syntax doesn't accept oil:all shopt block syntax should accept oil:all May 26, 2022
@andychu
Copy link
Contributor

andychu commented Jul 28, 2022

@andychu andychu closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants