Make login.nu work when using nu as a login shell (#6134)

* Make login.nu work when using nu as a login shell

Fixes #6055

Signed-off-by: nibon7 <nibon7@163.com>

* fix clippy warning

Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
nibon7 2022-07-26 22:41:05 +08:00 committed by GitHub
parent 6b4e577032
commit b2c466bca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,7 +92,9 @@ fn main() -> Result<()> {
// Would be nice if we had a way to parse this. The first flags we see will be going to nushell
// then it'll be the script name
// then the args to the script
let mut args = std::env::args().skip(1);
let mut args = std::env::args();
let argv0 = args.next();
while let Some(arg) = args.next() {
if !script_name.is_empty() {
args_to_script.push(escape_for_script_arg(&arg));
@ -122,6 +124,12 @@ fn main() -> Result<()> {
args_to_nushell.insert(0, "nu".into());
if let Some(argv0) = argv0 {
if argv0.starts_with('-') {
args_to_nushell.push("--login".into());
}
}
let nushell_commandline_args = args_to_nushell.join(" ");
let parsed_nu_cli_args = parse_commandline_args(&nushell_commandline_args, &mut engine_state);