sed - output already produced is lost when a runtime error stops processing
Los mantenedores suelen responder en 1 día
@Himanshu-singh04 ya está trabajando en esto.
Desde el 10/11/2026.
- #668 de @Himanshu-singh04 — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 86/100
Línea de trabajo
Lee process_all_files y process_file en src/sed/processor.rs y céntrate en cómo se devuelven los errores antes de vaciar la salida. Reprodúcelo con el caso proporcionado test_output_kept_on_runtime_error y confirma que la prueba captura one\ntwo\n después del error en tiempo de ejecución. Se considera terminado cuando se conserva la salida almacenada en búfer de las líneas anteriores y el comando sigue indicando un fallo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When sed stops with a runtime error partway through its input, GNU sed has already written the
output for the earlier lines. uutils sed loses it when it reads a file operand and stdout is not
a terminal (a file or a pipe): everything still in the output buffer is dropped.
(The scanner report also mentions w files losing data when the script has a backward branch
loop; that part did not reproduce on current main, so it is left out.)
Reproduction
$ printf 'a\nb\nc\n' > in3
Rust (incorrect)
$ ./target/release/sed '3s//X/' in3 > out.txt; echo "rc=$?"; cat out.txt
sed: <script argument 1>:1:1: 'in3':3 error: no previous regular expression
rc=2
# out.txt is empty
GNU (correct)
$ /usr/bin/sed '3s//X/' in3 > out.txt; echo "rc=$?"; cat out.txt
/usr/bin/sed: -e expression #1, char 0: no previous regular expression
rc=1
a
b
(The exit status and message format also differ; those are separate issues. This one is only
about the lost a and b.)
Root cause
process_all_files in src/sed/processor.rs returns as soon as process_file fails
(src/sed/processor.rs:1005), so the output buffer for the current file is never flushed (nor
is named_writer::flush_all() at src/sed/processor.rs:1025-1026 reached):
context.input_name = path;
process_file(commands.clone(), &mut reader, output, context)?;
...
// Flush all output files
named_writer::flush_all()?;
Test
#[test]
fn test_output_kept_on_runtime_error() {
let temp_dir = assert_fs::TempDir::new().unwrap();
let input = temp_dir.child("in");
input.write_str("one\ntwo\nthree\n").unwrap();
new_ucmd!()
.args(&["3s//X/", input.path().to_str().unwrap()])
.fails()
.stdout_is("one\ntwo\n");
}
The output is lost with a pipe as well as with a file (sed '3s//X/' in3 | cat prints nothing),
so the default uutests capture should show the bug.
Reported by Anthropic's OSS Scanner (ANT-2026-D6QYNXKH).
- Lenguaje dominante
- Rust
- Estrellas
- 123
- Forks
- 53
- Merge medio
- 2 d 8 h
- PR fusionados (30 d)
- 40
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de uutils/sed
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
sed - with `--posix`, `-e 'i\'` takes the next `-e` as its textPosiblemente ocupada @yunusarda-sudo la tomó hace 14 días. Abiertobug gnu-compat good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
sed - script parser skips CR, VT, FF (and 0x85, 0xA0) as blanks; GNU skips only space and tabPosiblemente ocupada @Himanshu-singh04 la tomó hace 22 días. Abiertobug gnu-compat good first issue oss-scanner
Dificultad 2/5 1-3 horas Aptitud para principiantes 89/100
Los mantenedores suelen responder en 1 día
-
sed - with `-s` or `-i`, the file read by `R` is not restarted for each input filePosiblemente ocupada @Himanshu-singh04 la tomó hace 22 días. Abiertobug gnu-compat good first issue oss-scanner
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
sed - unknown POSIX class names like `[[:foo:]]` or `[[:word:]]` are accepted instead of rejectedPosiblemente ocupada @draarivpatel-ui la tomó hace 7 días. Abiertobug gnu-compat good first issue oss-scanner
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
uutils/sed#646 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de uutils/sed
Issues similares
-
autofix:working
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
libracoder/kiri#1138 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
roc-lang/basic-webserver#277 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
samkerrcode/opengent#113 ·
Los mantenedores suelen responder en 1 día
-
app bug session
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día