diff --git a/crates/nu-cli/src/commands/open.rs b/crates/nu-cli/src/commands/open.rs index 720ffa70d4..8bdc0a59cf 100644 --- a/crates/nu-cli/src/commands/open.rs +++ b/crates/nu-cli/src/commands/open.rs @@ -305,132 +305,6 @@ pub async fn fetch( span, )) } - /* - cwd.push(Path::new(location)); - if let Ok(cwd) = dunce::canonicalize(cwd) { - match std::fs::read(&cwd) { - Ok(bytes) => match std::str::from_utf8(&bytes) { - Ok(s) => Ok(( - cwd.extension() - .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), - Tag { - span, - anchor: Some(AnchorLocation::File(cwd.to_string_lossy().to_string())), - }, - )), - Err(_) => { - //Non utf8 data. - match (bytes.get(0), bytes.get(1)) { - (Some(x), Some(y)) if *x == 0xff && *y == 0xfe => { - // Possibly UTF-16 little endian - let utf16 = read_le_u16(&bytes[2..]); - - if let Some(utf16) = utf16 { - match std::string::String::from_utf16(&utf16) { - Ok(s) => Ok(( - cwd.extension() - .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )), - Err(_) => Ok(( - None, - UntaggedValue::binary(bytes), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )), - } - } else { - Ok(( - None, - UntaggedValue::binary(bytes), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )) - } - } - (Some(x), Some(y)) if *x == 0xfe && *y == 0xff => { - // Possibly UTF-16 big endian - let utf16 = read_be_u16(&bytes[2..]); - - if let Some(utf16) = utf16 { - match std::string::String::from_utf16(&utf16) { - Ok(s) => Ok(( - cwd.extension() - .map(|name| name.to_string_lossy().to_string()), - UntaggedValue::string(s), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )), - Err(_) => Ok(( - None, - UntaggedValue::binary(bytes), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )), - } - } else { - Ok(( - None, - UntaggedValue::binary(bytes), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )) - } - } - _ => Ok(( - None, - UntaggedValue::binary(bytes), - Tag { - span, - anchor: Some(AnchorLocation::File( - cwd.to_string_lossy().to_string(), - )), - }, - )), - } - } - }, - Err(_) => Err(ShellError::labeled_error( - "File could not be opened", - "file not found", - span, - )), - } - } else { - Err(ShellError::labeled_error( - "File could not be opened", - "file not found", - span, - )) - } - */ } fn convert_via_utf8(