如何设置 Cygwin 以使用 DOS 文件结尾? [英] How to set up Cygwin to use DOS file endings?

查看:33
本文介绍了如何设置 Cygwin 以使用 DOS 文件结尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:

当我运行一个用 CR+LF 行结尾存储的 shell 脚本时,出现以下错误:

When I run a shell script, that has been stored with CR+LF line endings, I get following error:

myscript.sh: line 1: cd: $'somedir\\someotherdir\r': No such file or directory

我研究了这个问题,并且有一个 Cygwin shell 的解决方案,找到了 这里:

I have researched the problem and there is a solution for Cygwin shell, found here:

  1. 创建一个 .bashrc 文件
  2. 把这个放在里面:

  1. Create a .bashrc file
  2. Put this inside:

export SHELLOPTS
set -o igncr

  • 重新加载 Cygwin 外壳
  • 但是,我使用 Cmder 并且我想在其中应用它.但是我不知道怎么做.正如此处所述,Cygwin 曾经有一个选项来设置使用DOS 文件结尾作为安装过程中的默认值,但摆脱了它(不知道为什么).

    However, I use Cmder and I'd like to apply this in it. But, I do not know how. As noted here, Cygwin used to have an option to set the use of DOS file endings as a default during installation, but got rid of it (no idea why).

    最奇怪的是我在旧电脑上也有相同的设置,还有 Windows 10,一切都运行良好,即使是 CRLF 结尾...

    The weirdest thing of all is that I have the same setup on my older computer, also Windows 10, and everything works well, even with CRLF endings...

    推荐答案

    您也可以使用可以与 Cygwin 一起安装的 dos2unix.

    You can also use dos2unix which can be installed with Cygwin.

    这篇关于如何设置 Cygwin 以使用 DOS 文件结尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆