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

source does not execute main as default #5257

Closed
JPBeckner opened this issue Apr 20, 2022 · 1 comment · Fixed by #6118
Closed

source does not execute main as default #5257

JPBeckner opened this issue Apr 20, 2022 · 1 comment · Fixed by #6118
Milestone

Comments

@JPBeckner
Copy link

JPBeckner commented Apr 20, 2022

Describe the bug

Invoking source --help it says:

(...) Runs foo.nu in current context and call the `main` command automatically, (...)

But it does not happens:

/home/me/nu-report〉touch foo.nu                                                                                   04/20/2022 11:06:06 AM
/home/menu-report〉nvim ./foo.nu                                                                                  04/20/2022 11:06:11 AM
/home/menu-report〉cat ./foo.nu                                                                                   04/20/2022 11:06:25 AM
def main [] { echo 'Hi!' }
/home/me/nu-report〉chmod +x ./foo.nu                                                                              04/20/2022 11:06:28 AM
/home/me/nu-report〉source ./foo.nu                                                                                04/20/2022 11:06:32 AM
/home/me/nu-report〉source ./foo.nu; main                                                                          04/20/2022 11:06:46 AM
Hi!

How to reproduce

  1. Create a .nu file with the content: def main [] { echo 'Hi!' }
touch foo.nu
nvim ./foo.nu  # write the file
cat ./foo.nu
# def main [] { echo 'Hi!' }
  1. Give execution permission to the file.
chmod +x ./foo.nu
  1. Try source
source ./foo.nu
# nothing
source ./foo.nu; main
# Hi!

### Expected behavior

Is expected that `source` invokes `main` by default, as informed.

### Screenshots

![image](https://user-images.githubusercontent.com/43730756/164250746-5669ad2c-e563-4e50-b7c0-8920f4c8ef20.png)


### Configuration

![image](https://user-images.githubusercontent.com/43730756/164250985-1189aab1-b85b-4ed3-bb33-a98c4aee48fd.png)
| key                | value                               |
| ------------------ | ----------------------------------- |
| version            | 0.61.0                              |
| branch             |                                     |
| tag                |                                     |
| build_os           | linux-x86_64                        |
| rust_version       | rustc 1.60.0 (7737e0b5c 2022-04-04) |
| rust_channel       | stable-x86_64-unknown-linux-gnu     |
| cargo_version      | cargo 1.60.0 (d1fd9fe 2022-03-01)   |
| pkg_version        | 0.61.0                              |
| build_time         | 2022-04-20 09:56:20 -03:00          |
| build_rust_channel | release                             |
| features           | default, trash, which, zip          |
| installed_plugins  |                                     |


### Additional context

_No response_
@fdncred
Copy link
Collaborator

fdncred commented Apr 20, 2022

i thought main was only invoked if launching a nushell script like nu script_name.nu paramaters versus with source? it seems to work that way for me with your example foo.nu script.

image

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 a pull request may close this issue.

3 participants