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

Code before:

                if !file_glob.item.is_expand() {
                    input_files.push(InputFile::Path(file_path));
                    continue;
                }

                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));

Review comment (suggestion):
I don't think we currently expand globs with `{}`

![image](https://github.com/user-attachments/assets/e6db6c38-e3b0-4b07-8594-95e7a012b3a9)


Code after:

                if !file_glob.item.is_expand() {
                    input_files.push(InputFile::Path(file_path));
                    continue;
                }

                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,