hashsum: Drop --no-names (#9762)

Co-authored-by: oech3 <>
This commit is contained in:
oech3 2025-12-22 18:17:28 +09:00 committed by GitHub
parent aacbeb5828
commit 2b67abe741
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 3 additions and 46 deletions

View file

@ -216,7 +216,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
algo_kind: algo,
output_format,
line_ending,
no_names: false,
};
perform_checksum_computation(opts, files)?;

View file

@ -18,7 +18,6 @@ hashsum-help-ignore-missing = don't fail or report status for missing files
hashsum-help-warn = warn about improperly formatted checksum lines
hashsum-help-zero = end each output line with NUL, not newline
hashsum-help-length = digest length in bits; must not exceed the max for the blake2 algorithm and must be a multiple of 8
hashsum-help-no-names = Omits filenames in the output (option not present in GNU/Coreutils)
hashsum-help-bits = set the size of the output (only for SHAKE)
# Algorithm help messages

View file

@ -15,7 +15,6 @@ hashsum-help-ignore-missing = ne pas échouer ou rapporter le statut pour les fi
hashsum-help-warn = avertir des lignes de somme de contrôle mal formatées
hashsum-help-zero = terminer chaque ligne de sortie avec NUL, pas de retour à la ligne
hashsum-help-length = longueur de l'empreinte en bits ; ne doit pas dépasser le maximum pour l'algorithme blake2 et doit être un multiple de 8
hashsum-help-no-names = Omet les noms de fichiers dans la sortie (option non présente dans GNU/Coreutils)
hashsum-help-bits = définir la taille de la sortie (uniquement pour SHAKE)
# Messages d'aide des algorithmes

View file

@ -3,7 +3,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore (ToDO) algo, algoname, bitlen, regexes, nread, nonames
// spell-checker:ignore (ToDO) algo, algoname, bitlen, regexes, nread
use std::ffi::{OsStr, OsString};
use std::iter;
@ -211,10 +211,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
return Err(ChecksumError::StrictNotCheck.into());
}
let no_names = *matches
.try_get_one("no-names")
.unwrap_or(None)
.unwrap_or(&false);
let line_ending = LineEnding::from_zero_flag(matches.get_flag("zero"));
let algo = SizedAlgoKind::from_unsized(algo_kind, length)?;
@ -229,7 +225,6 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
/* base64: */ false,
),
line_ending,
no_names,
};
let files = matches.get_many::<OsString>(options::FILE).map_or_else(
@ -384,19 +379,6 @@ fn uu_app_opt_length(command: Command) -> Command {
)
}
pub fn uu_app_b3sum() -> Command {
uu_app_b3sum_opts(uu_app_common())
}
fn uu_app_b3sum_opts(command: Command) -> Command {
command.arg(
Arg::new("no-names")
.long("no-names")
.help(translate!("hashsum-help-no-names"))
.action(ArgAction::SetTrue),
)
}
pub fn uu_app_bits() -> Command {
uu_app_opt_bits(uu_app_common())
}
@ -414,7 +396,7 @@ fn uu_app_opt_bits(command: Command) -> Command {
}
pub fn uu_app_custom() -> Command {
let mut command = uu_app_b3sum_opts(uu_app_opt_bits(uu_app_common()));
let mut command = uu_app_opt_bits(uu_app_common());
let algorithms = &[
("md5", translate!("hashsum-help-md5")),
("sha1", translate!("hashsum-help-sha1")),

View file

@ -34,9 +34,6 @@ pub struct ChecksumComputeOptions {
/// Whether to finish lines with '\n' or '\0'.
pub line_ending: LineEnding,
/// (non-GNU option) Do not print file names
pub no_names: bool,
}
/// Reading mode used to compute digest.
@ -218,12 +215,6 @@ fn print_untagged_checksum(
sum: &String,
reading_mode: ReadingMode,
) -> UResult<()> {
// early check for the "no-names" option
if options.no_names {
print!("{sum}");
return Ok(());
}
let (escaped_filename, prefix) = if options.line_ending == LineEnding::Nul {
(filename.to_string_lossy().to_string(), "")
} else {

View file

@ -8,7 +8,7 @@ use rstest::rstest;
use uutests::new_ucmd;
use uutests::util::TestScenario;
use uutests::util_name;
// spell-checker:ignore checkfile, nonames, testf, ntestf
// spell-checker:ignore checkfile, testf, ntestf
macro_rules! get_hash(
($str:expr) => (
$str.split(' ').collect::<Vec<&str>>()[0]
@ -41,19 +41,6 @@ macro_rules! test_digest {
get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture(INPUT_FILE).succeeds().no_stderr().stdout_str()));
}
#[test]
fn test_nonames() {
let ts = TestScenario::new(util_name!());
// EXPECTED_FILE has no newline character at the end
if DIGEST_ARG == "--b3sum" {
// Option only available on b3sum
assert_eq!(format!("{0}\n{0}\n", ts.fixtures.read(EXPECTED_FILE)),
ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("--no-names").arg(INPUT_FILE).arg("-").pipe_in_fixture(INPUT_FILE)
.succeeds().no_stderr().stdout_str()
);
}
}
#[test]
fn test_check() {
let ts = TestScenario::new(util_name!());