42-Ikole-Systems / TMK-SH

An awesome POSIX compliant shell.
MIT License
0 stars 0 forks source link

Implement Quote Removal #37

Open Tishj opened 1 year ago

Tishj commented 1 year ago

Figured this was the easiest part of Expansion to start with

Tishj commented 1 year ago

I've written the logic, completely untested still 😅

Having some trouble figuring out if this specifically needs to happen at execution or doing this while parsing would already be acceptable. And how this would fit with the other expansions that need to happen.

I'm thinking of first adding this to cmd_prefix, but that is produced from a WORD token, which doesn't have any "rules" associated with it

The WORD tokens shall have the word expansion rules applied to them immediately before the associated command is executed, not at the time the command is parsed.

mraasvel commented 1 year ago

I believe most of it will happen in execution, since subsequent command expansion can be affected by previous commands. Some things like heredoc word quote removal happens in parser but it's quite minimal afaik.

mraasvel commented 1 year ago

I wonder if it's worth making some generic state machine tokenizer, i.e. defining only the states, transitions, and token delimiting. Since expansions iteration is somewhat similar to the lexer, and for arithmetic we'll also need some lexer. Some states are not so straight forward though so I don't really see it immediately.