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

Close a bunch of holes in external command args #632

Merged
merged 3 commits into from Sep 10, 2019

Conversation

wycats
Copy link
Contributor

@wycats wycats commented Sep 9, 2019

Previously, there was a single parsing rule for "bare words" that
applied to both internal and external commands.

This meant that, because cargo +nightly needed to work, we needed to
add + as a valid character in bare words.

The number of characters continued to grow, and the situation was
becoming untenable. The current strategy would eventually eat up all
syntax and make it impossible to add syntax like @foo to internal
commands.

This patch significantly restricts bare words and introduces a new token
type (ExternalWord). An ExternalWord expands to an error in the
internal syntax, but expands to a bare word in the external syntax.

ExternalWords are highlighted in grey in the shell.

Previously, there was a single parsing rule for "bare words" that
applied to both internal and external commands.

This meant that, because `cargo +nightly` needed to work, we needed to
add `+` as a valid character in bare words.

The number of characters continued to grow, and the situation was
becoming untenable. The current strategy would eventually eat up all
syntax and make it impossible to add syntax like `@foo` to internal
commands.

This patch significantly restricts bare words and introduces a new token
type (`ExternalWord`). An `ExternalWord` expands to an error in the
internal syntax, but expands to a bare word in the external syntax.

`ExternalWords` are highlighted in grey in the shell.
@wycats
Copy link
Contributor Author

wycats commented Sep 10, 2019

I fixed this test failure in part by creating a new "pattern" token, which separates bare words from globs.

image

Commands that want to take globs now say SyntaxType::Pattern rather than SyntaxType::Path, which produces this error if appropriate.

Bare words now represent literal file names, and globs are a different
syntax shape called "Pattern". This allows commands like `cp` to ask for
a pattern as a source and a literal file as a target.

This also means that attempting to pass a glob to a command that expects
a literal path will produce an error.
@andrasio andrasio merged commit f47349c into master Sep 10, 2019
@andrasio andrasio deleted the improve-external-words branch September 10, 2019 17:43
Hofer-Julian pushed a commit to Hofer-Julian/nushell that referenced this pull request Jan 27, 2023
Remove hidden files from the result of `ls` command
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.

None yet

2 participants