ks0n / ubsh

UnBloated (or Undefined Behavior...) shell. A small and lightweight non-POSIX shell.
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Add SPECS.md #2

Open CohenArthur opened 4 years ago

CohenArthur commented 4 years ago

Refine it enough so that it is readable and understanble. The specs will of course evolve through the project, but they need to be here as a starting point.

n1tram1 commented 4 years ago

https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html this but without the bullshit

n1tram1 commented 4 years ago

Any comments ?

CohenArthur commented 4 years ago

I agree with that, but we need to decide what we categorize as bullshit :D

n1tram1 commented 4 years ago

I can't think of other things now. Any ideas @Skallwar @CohenArthur @08A ?

Skallwar commented 4 years ago
n1tram1 commented 4 years ago

I believe a needed feature is JITing shell, that way we will have a very fast shell.

CohenArthur commented 4 years ago

If we agree that not executing existing POSIX scripts is okay, then I can think of a few:

"${foo-bar"}

yields bar when foo is not defined, and is an invalid substitution when foo is defined, in many historical shells. The differences in processing the "${...}" form have led to inconsistencies between historical systems. A consequence of this rule is that single-quotes cannot be used to quote the '}' within "${...}"; for example:

unset bar foo="${bar-'}'}"

is invalid because the "${...}" substitution contains an unpaired unescaped single-quote. The can be used to escape the '}' in this example to achieve the desired result:

unset bar foo="${bar-}}"

The differences in processing the "${...}" form have led to inconsistencies between the historical System V shell, BSD, and KornShells, and the text in the Shell and Utilities volume of POSIX.1-2017 is an attempt to converge them without breaking too many applications. The only alternative to this compromise between shells would be to make the behavior unspecified whenever the literal characters single-quote, '{', '}', and '' appear within "${...}". To write a portable script that uses these values, a user would have to assign variables; for example:

squote=\' dquote=\" lbrace='{' rbrace='}' ${foo-$squote$rbrace$squote}

None of this ^ complex variable expansion crap

I'd basically like to vote out anything that isn't crystal clear or that does not make sense in the spec.

CohenArthur commented 4 years ago

I believe a needed feature is JITing shell, that way we will have a very fast shell.

Once we have a shell we can talk about JITting it :D

n1tram1 commented 4 years ago

$ alias while="/" has to be removed. Aliasing reserved keywords has to be forbidden

this is actually easy to implement now that I understand how to write a shell