expand/unexpand: a bare `-` operand is taken as an obsolete `-N` tab option, so standard input is skipped
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
Línea de trabajo
Empieza leyendo expand_shortcuts() en src/uu/unexpand/src/unexpand.rs y src/uu/expand/src/expand.rs, donde el issue identifica el - sin argumentos como una coincidencia con la opción obsoleta de tabulación. Revisa las pruebas existentes de expand y unexpand y luego reproduce el comportamiento con printf 'stdin\n' | unexpand - f y el comando correspondiente de expand. Se considera terminado cuando un - sin argumentos lee de la entrada estándar junto con el archivo indicado y unexpand no activa --first-only por error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
expand and unexpand treat a bare - as an empty obsolete -N[,M] tab-stop option instead of the standard-input operand. As a result:
expand - FILEandunexpand - FILEnever read standard input; they print only FILE and exit 0.- In
unexpand, the obsolete option also turns on--first-only, sounexpand -t N -converts only leading blanks, andunexpand --first-only -fails with "the argument '--first-only' cannot be used multiple times".
With - as the only operand the output usually looks right, because stdin is read by default anyway.
The GNU manual (expand invocation, and the same sentence in unexpand invocation) says:
expandwrites the contents of each given FILE, or standard input if none are given or for a FILE of-, to standard output.
and for unexpand -t: "This option implies the -a option." GNU coreutils 9.12:
printf 'stdin\n' | unexpand - <(printf 'file\n')
# GNU 9.12: stdin / file
# uutils: file
printf 'stdin\n' | expand - <(printf 'file\n')
# GNU 9.12: stdin / file
# uutils: file
printf 'a b\n' | unexpand -t 3 - | od -An -c
# GNU 9.12: a \t b \n
# uutils: a b \n
Versions. uutils main 342b6f7bd10adee39809516f56d86425422cc9ec (2026-10-22) and the 0.12.0 release binary, macOS 26 aarch64, LC_ALL=C, compared with GNU coreutils 9.12.
Where. expand_shortcuts() in src/uu/unexpand/src/unexpand.rs and in src/uu/expand/src/expand.rs accepts any argument that starts with - and has only digits or commas after it. For a bare - the rest is empty, so it matches; unexpand then also adds --first-only.
Related: the unexpand --first-only - row in #15254 is this bug. Open PR #14291 changes expand_shortcuts() for hyphen-leading tab lists after -t, but a bare - elsewhere still matches there. #11091 (no output for interactive stdin) is a different problem.
Found with an automated differential tester that compares uutils with GNU 9.12. I reproduced it by hand on main and on 0.12.0.
Reproduction steps
export LC_ALL=C
cd "$(mktemp -d)"
printf 'file\n' > f
printf 'stdin\n' | unexpand - f
# GNU 9.12: stdin, then file
# uutils: file
- Lenguaje dominante
- Rust
- Estrellas
- 24.3k
- Forks
- 2.1k
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 347
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- 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/coreutils
-
chmod -v: missing 'could not be accessed' line for operands that can't be stat'edPosiblemente ocupada @emirmrkaljevic la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
chown, chgrp: 'cannot dereference' instead of 'cannot access' for a missing operandPosiblemente ocupada @emirmrkaljevic la tomó hace 1 día. AbiertoU - chgrp U - chown
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
split: -b and -l ignore short writes, exit 0 with a truncated last chunkPosiblemente ocupada @binhvq la tomó hace 1 día. Abiertogood first issue I - Incorrect oss-scanner U - split
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
uutils/coreutils#15820 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
df: prints raw control characters in file and mount names, unlike GNUPosiblemente ocupada @aj-codespy la tomó hace 2 días. Abiertogood first issue I - Incorrect oss-scanner U - df
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
uutils/coreutils#15817 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
quoting_style: ! in double quotes allows command injection when pastedPosiblemente ocupada @fixfon la tomó hace 1 día. Abiertogood first issue I - Incorrect oss-scanner U - All (uucore) U - ls
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de uutils/coreutils
Issues similares
-
QuartoHub: have the Document name before the filename in the browser tabPosiblemente ocupada @cscheid la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
quarto-dev/q2#930 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
muse P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
HerringtonDarkholme/hd-lang#923 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
longbridge/gpui-kit#3712 ·
Los mantenedores suelen responder en 1 día
-
documentation enhancement SIEM
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ADORSYS-GIS/wazuh-agent-status#265 ·
Los mantenedores suelen responder en 2 días