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

require strings to obviously be strings. maybe. #9336

Open
colemickens opened this issue Jun 1, 2023 · 3 comments
Open

require strings to obviously be strings. maybe. #9336

colemickens opened this issue Jun 1, 2023 · 3 comments
Labels
enhancement New feature or request needs-triage An issue that hasn't had any proper look

Comments

@colemickens
Copy link

Related problem

I am getting tripped up multiple times a day by one single thing -- unquoted strings being treated as strings.

I really wish that nushell didn't coerce anything it doesn't recognize to a string.

let success = true
...
if success {

}

gives a string error. Passing gcrootsdir to a external-command just silently, when I'd really meant $gcrootsdir, which meant I'd silently been writing to the completely wrong directory.

Describe the solution you'd like

  1. Nushell does not coerce unquoted strings to strings.

Granted, as I type that, I'm not really sure how that would be handled, given that random flags and arguments to external commands are indeed generally unquoted strings.

Describe alternatives you've considered

No response

Additional context and details

No response

@colemickens colemickens added enhancement New feature or request needs-triage An issue that hasn't had any proper look labels Jun 1, 2023
@fdncred
Copy link
Collaborator

fdncred commented Jun 1, 2023

success here is not a string

> let success = true
> $success | describe
bool

When you declare variables you need to reference them with $variable_name like most scripting languages. Maybe I'm not understanding?

@colemickens
Copy link
Author

Right, but if success { ... } gives a "cannot convert string to bool" error. Which I've stared at a few times and gone... "no, it's not".

Maybe it would just be enough to have hints on errors. Like:

"Cannot convert string to bool (did you mean $success instead of success"

Given the external commands and "you're just doing it wrong", maybe there's no bug/feature here. But I've had this thought a few times and wanted to bring it up at least.

@fdncred
Copy link
Collaborator

fdncred commented Jun 1, 2023

someone may be able to hook up a 'did you mean' to this. i'm not sure how to do that myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

No branches or pull requests

2 participants