在git中如何区分Microsoft Word文档?

插口

我一直在这里按照本指南来学习如何区分Microsoft Word文档,但是遇到了这个错误:

Usage:  /usr/bin/docx2txt.pl [infile.docx|-|-h] [outfile.txt|-]
        /usr/bin/docx2txt.pl < infile.docx
        /usr/bin/docx2txt.pl < infile.docx > outfile.txt

        In second usage, output is dumped on STDOUT.

        Use '-h' as the first argument to get this usage information.

        Use '-' as the infile name to read the docx file from STDIN.

        Use '-' as the outfile name to dump the text on STDOUT.
        Output is saved in infile.txt if second argument is omitted.

Note:   infile.docx can also be a directory name holding the unzipped content
        of concerned .docx file.

fatal: unable to read files to diff

要解释我是如何导致该错误的:我在要与之区别的存储库中创建了一个.gitattributes。.gitattributes看起来像这样:

*.docx diff=word
*.docx difftool=word

我已经安装了docx2txt。我在Linux上。我创建了一个名为docx2txt的文件,其中包含以下内容:

#!/bin/bash
docx2txt.pl $1 -

$ chmod a+xdocx2txt并将docx2txt放在/ usr / bin /

我做了:

$ git config diff.word.textconv docx2txt

然后尝试区分两个Microsoft Word文档。那是我收到上面提到的错误的时间。

我想念什么?如何解决此错误?

PS:我不知道我的外壳是否可以找到docx2txt,因为当我这样做时:

$ docx2txt

我的终端死机,处理了一些东西,但是什么也没输出,当我执行以下命令时,会发生这种情况:

$ man docx2txt
No manual entry for docx2txt
$ docx2txt --help
Can't read docx file <--help>!

进度更新:我将docx2txt更改为

#!/bin/bash
docx2txt.pl "$1" -

正如pmod建议的那样,现在git diff <commit>可以在命令行中使用!好极了!但是,当我尝试

$ git difftool <commit>

git启动kdiff3,然后出现此弹出错误:

Some input characters could not be converted to valid unicode.
You might be using the wrong codec. (e.g. UTF-8 for non UTF-8 files).
Don't save the result if unsure. Continue at your own risk.
Affected input files are in A, B.

...并且文件中的所有字符都是巨型字符。命令行可以正确显示diff文本,但是由于某些原因kdiff3不能正确显示diff文本。

如何在kdiff3或其他gui工具中正确显示差异文本?我应该将kdiff3更改为其他工具吗?

附加:由于以下命令,我的外壳似乎无法找到docx2txt:

$ which doctxt
which: no doctxt in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)

$ which docx2txt
/usr/bin/docx2txt
pmod

doc2txt.pl根据用途期望恰好两个参数或零。在第一个(您的)情况下,参数是文件名或“-”。因此,对于文件名中至少有一个空格作为第一个参数传递的情况,您的包装器脚本看起来是正确的。在这种情况下,$ 1文件名扩展后,部分将作为单独的参数传递,因此该工具将输出使用情况信息,因为它读取的参数超过2个。

尝试使用引号来避免文件名拆分:

#!/bin/bash
docx2txt.pl "$1" -

PS:我不知道我的外壳是否可以找到docx2txt

你可以用

$ which docx2txt

如果看到路径,则可以找到工具(二进制或可运行脚本)(基于PATH环境变量)。

因为当我这样做时:

$ docx2txt

我的终端死机,正在处理某些内容,但未输出任何内容

不带参数的脚本将执行doc2txt.pl-根据工具的使用情况,该命令将期望输入文件通过STDIN传递,即您键入的内容。因此,它看起来像是挂起并处理某些东西,但实际上仅捕获了您的输入。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章