-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
can't redefine assignment builtins, 'builtin', or 'command' as functions #654
Comments
Well, all of those that can't be overrided seem to be POSIX special builtins except for On another note, I just realized that the special builtins means that the famous fork bomb is not POSIX-compatible. So I guess that's one more for Oil's "safety" (until this gets fixed, anyway) ¯\_(ツ)_/¯ |
Yes I haven't had time to look into this more closely, but I believe the rules in Oil are basically:
If this is blocking anything specific I'll take a closer look |
@akinomyoga Let's talk about these related issues here. I don't have a problem with the behavior of redefining assignment builtins and allowing The underlying reason is that assignment builtins are different than builtins in all shells with regard to word splitting. Consider:
If assignment builtins were evaluated like regular builtins, then So what we have to do is look at the "first" word dynamically while evaluating to determine if it's an assignment builtin:
Oil actually implements a more consistent zsh-like behavior. As far as I remember the behavior of bash didn't make much sense. There were lots of corners that were unattended to. So in summary I think it's possible but not straightforward. |
Another reason is that So the
|
Somewhat related: I ran into a manifestation of the same difference between bash and zsh while testing #696 to implement In zsh assignment builtins are more principled and I guess the point is that what the last word is is unclear in the case of assignment builtins, but it's clear for regular builtins. And this is one reason we have to parse assignment builtins up front, to recognize the non-words like So there are really 3 kinds of builtins: special, assignment, and "normal" ones. |
@andychu Thank you for your reply! I'm sorry that my confusing writing. I was not thinking about making assignment builtins redefinable but just thought about supporting the [ Note: Nevertheless, I thought that it is natural to support For the syntax analysis, Bash actually specially treats the literal word
We can observe how Bash treats the words in assignment builtins in the following more explicit way: $ function declare { printf '[%s]\n' "$@"; }
$ declare a=1 b=(1 2 3) c
[a=1]
[b]
[c] |
I'm going through issues labeled "divergence", and reviewing them... I realize I didn't fully respond to this. I would say the special cases of
I think OSH behavior is very well defined and avoids these confusing (and undocumented) issues! But yes it's slightly incompatible. I ran into some similar things with extended globs recently! For example, Like
So IMO bash has a deep confusion between parsing and execution... the parsing of (Removed the "divergence" label because that's for things that we know we should fix. This is under "compatibility" which may not be fixed. Comments welcome!) |
from #620
Overridable/protected builtins
ble.sh overrides the builtins
bind
,exit
,read
andtrap
. I found thattrap
cannot be overridden as well in Oil. I checked which Bash builtin equivalent can be overridden in Oil with the following script:I found that, in addition to control flow keywords (
exit
,break
,continue
andreturn
), the declare family (declare
,export
,local
,readonly
,typeset
) andunset
, parameter manipulation (set
andshift
) and other builtinsbuiltin
,eval
,exec
,times
,trap
,.
and:
are not allowed to be overridden. I haven't tested Oil specific builtins.It is interesting to observe that one can override
command
even though one cannot overridebuiltin
. One can overridesource
even though one cannot override.
. Is the list of overridable builtins and protected builtins documented somewhere?Originally posted by @akinomyoga in #620 (comment)
The text was updated successfully, but these errors were encountered: