Glob 获得与coreutils sha224sum相同的SHA-224和因子

Glob 获得与coreutils sha224sum相同的SHA-224和因子,glob,checksum,sha,factor-lang,Glob,Checksum,Sha,Factor Lang,使用Factor的glob和shell的glob,输出是相同的。输出上的diff显示它们完全匹配 $ echo * a b c $ cat * file 1 file 2 file 3 $ factor -e=" \ > USING: globs io sequences sorting io.files io.encodings.utf8 ; \ > \"*\" glob natural-sort [ utf8 file-lines ] map concat [ print ]

使用Factor的glob和shell的glob,输出是相同的。输出上的
diff
显示它们完全匹配

$ echo *
a b c
$ cat *
file 1
file 2
file 3
$ factor -e=" \ 
> USING: globs io sequences sorting io.files io.encodings.utf8 ; \ 
> \"*\" glob natural-sort [ utf8 file-lines ] map concat [ print ] each "
file 1
file 2
file 3
但是校验和不匹配,
md5
校验和也不会匹配。为什么会这样?如何获得与coreutils
sha224sum
中相同的因子校验和


将编码更改为
ascii
不会更改输出,
“\n”连接sha-224校验和字节
,而不是
校验和行

这种奇怪的行为是由于校验和行中的错误造成的

感谢您发现问题,以及Factor邮件列表上的代码:

此代码:

$ factor -e=" \
> USING: math.parser checksums checksums.sha globs io sequences sorting io.files io.encodings.utf8 ; \
> \"*\" glob natural-sort [ utf8 file-lines ] map concat sha-224 checksum-lines bytes>hex-string print "

0feaf7d5c46b802404760778091ed1312ba82d4206b9f93c35570a1a
$ cat * | sha224sum
d1240479399e5a37f8e62e2935a7ac4b9352e41d6274067b27a36101
给出相同的哈希:

D1240479399E5A37F8E62E29335A7AC4B9352E41D6274067B27A36101

还认为:

另外,关于您得到的三种不同长度,“exercism/self-update/self-update.factor”在最后一行末尾缺少“\n”字符。这就是为什么你会得到令人惊讶的结果


如果您尝试对文件进行校验和,请确保它们都以尾随的换行符结尾。

您是否缺少“\n”连接anter concat?我认为因子代码是对3个文件内容的数组进行散列,校验和行与ascii 10连接,所以不是这样:/噢,缺少的是后面的换行符!这在邮件列表中得到了回答,如果在这里也能给出答案,那就太好了。@fedes。谢谢你的提醒,很抱歉打扰你c:别担心,我需要帮助的时候也会打扰你的!C:(事实上是约翰·哈珀发现了问题……应该归功于他,而不是我)@fedes。更新c:
[
    { "a" "b" "c" } 3 [1,b]
    [ number>string "file " prepend [ write ] curry
      ascii swap with-file-writer ] 2each

    "*" glob natural-sort [ utf8 file-lines ] map concat
    [ "\n" append ] map "" join  ! Add newlines between and at the end

    sha-224 checksum-bytes bytes>hex-string print
] with-test-directory