Repository: nushell/nushell
File: crates/nu-command/src/filesystem/utouch.rs (Rust)

Code before:

                let mut expanded_globs = glob(&file_path.to_string_lossy())
                    .unwrap_or_else(|_| {
                        panic!(
                            "Failed to process file path: {}",
                            &file_path.to_string_lossy()
                        )
                    })
                    .peekable();

                if expanded_globs.peek().is_none() {
                    let file_name = file_path.file_name().unwrap_or_else(|| {
                        panic!(
                            "Failed to process file path: {}",
                            &file_path.to_string_lossy()
                        )
                    });

                    if file_name.to_string_lossy().contains("*")
                        || file_name.to_string_lossy().contains("?")
                        || file_name.to_string_lossy().contains("{")
                        || file_name.to_string_lossy().contains("[")
                    {
                        return Err(ShellError::GenericError {
                            error: format!(
                                "Error while parsing file glob {}",
                                file_name.to_string_lossy()
                            ),
                            msg: format!(
                                "No matches found for glob pattern {}",
                                file_name.to_string_lossy()
                            ),
                            span: Some(file_glob.span),
                            help: Some(format!(
                                "Use quotes if you want to create a file named {}",
                                file_name.to_string_lossy()
                            )),
                            inner: vec![],
                        });
                    }

                    input_files.push(InputFile::Path(file_path));
                    continue;
                }

                input_files.extend(expanded_globs.filter_map(Result::ok).map(InputFile::Path));
            }
        }

        if let Err(err) = uu_touch::touch(
            &input_files,

Review comment (suggestion):
I think "No matches found for glob" is a fine error message here. We're not really parsing anything.

Code after:

                let mut expanded_globs = glob(&file_path.to_string_lossy())
                    .unwrap_or_else(|_| {
                        panic!(
                            "Failed to process file path: {}",
                            &file_path.to_string_lossy()
                        )
                    })
                    .peekable();

                if expanded_globs.peek().is_none() {
                    let file_name = file_path.file_name().unwrap_or_else(|| {
                        panic!(
                            "Failed to process file path: {}",
                            &file_path.to_string_lossy()
                        )
                    });

                    if is_glob(&file_name.to_string_lossy()) {
                        return Err(ShellError::GenericError {
                            error: format!(
                                "No matches found for glob {}",
                                file_name.to_string_lossy()
                            ),
                            msg: "No matches found for glob".into(),
                            span: Some(file_glob.span),
                            help: Some(format!(
                                "Use quotes if you want to create a file named {}",
                                file_name.to_string_lossy()
                            )),
                            inner: vec![],
                        });
                    }

                    input_files.push(InputFile::Path(file_path));
                    continue;
                }

                input_files.extend(expanded_globs.filter_map(Result::ok).map(InputFile::Path));
            }
        }

        if let Err(err) = uu_touch::touch(
            &input_files,
            &Options {
                no_create,
                no_deref,
                source,
                date: date_str,
                change_times,
                strict: true,