diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index ef27d221d8..b14ebd7b4f 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -12,6 +12,13 @@ const ENV_PATH_SEPARATOR_CHAR: char = ';'; #[cfg(not(target_family = "windows"))] const ENV_PATH_SEPARATOR_CHAR: char = ':'; +// Character used to separate directories in a Path Environment variable on windows is ";" +#[cfg(target_family = "windows")] +const LINE_SEPARATOR_CHAR: &str = "\r\n"; +// Character used to separate directories in a Path Environment variable on linux/mac/unix is ":" +#[cfg(not(target_family = "windows"))] +const LINE_SEPARATOR_CHAR: char = '\n'; + #[derive(Clone)] pub struct Char; @@ -59,6 +66,10 @@ static CHAR_MAP: LazyLock> = LazyLock::new(|| { "path_sep" => std::path::MAIN_SEPARATOR.to_string(), "psep" => std::path::MAIN_SEPARATOR.to_string(), "separator" => std::path::MAIN_SEPARATOR.to_string(), + "eol" => LINE_SEPARATOR_CHAR.to_string(), + "lsep" => LINE_SEPARATOR_CHAR.to_string(), + "line_sep" => LINE_SEPARATOR_CHAR.to_string(), + "lsep" => '\n'.to_string(), "esep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "env_sep" => ENV_PATH_SEPARATOR_CHAR.to_string(), "tilde" => '~'.to_string(), // ~ @@ -163,6 +174,9 @@ static NO_OUTPUT_CHARS: LazyLock> = LazyLock::new(|| { "crlf", "bel", "backspace", + "lsep", + "line_sep", + "eol", ] .into_iter() .collect() diff --git a/crates/nu-command/tests/commands/platform/char_.rs b/crates/nu-command/tests/commands/platform/char_.rs index 7a6bdc1309..eeaffd4e4a 100644 --- a/crates/nu-command/tests/commands/platform/char_.rs +++ b/crates/nu-command/tests/commands/platform/char_.rs @@ -8,5 +8,5 @@ fn test_char_list_outputs_table() { "# )); - assert_eq!(actual.out, "107"); + assert_eq!(actual.out, "113"); } diff --git a/crates/nu-command/tests/commands/platform/mod.rs b/crates/nu-command/tests/commands/platform/mod.rs index c37cc28c8c..d9d4c4cfc4 100644 --- a/crates/nu-command/tests/commands/platform/mod.rs +++ b/crates/nu-command/tests/commands/platform/mod.rs @@ -1,2 +1,3 @@ mod ansi_; +mod char_; mod kill;