이번 프로젝트를 하는데... 확장자가 없는 스크립트 파일이 bin 형식으로 올라갔는지
컴파일 에러가 난다. 이유인 즉 cygwin에서 쓰는 sh는 버전up 이 되면
\r\n 처리중 \r 을 안하기로 했단다... cygwin readme 어디엔가 나옴..
이를 피하기 위한 방법은 크게 2가지 정도 있는데...
1. igncr 을 설정하는 방법
set -o igncr
2. IFS에 \r를 추가하는 방법 이다.
IFS=$'\20\09\0D\0A'
회사 어떤 컴터에선 컴팔이 잘되는데.. 이유인즉 IFS에 \r 이 추가 되어 있더라...
안되는 컴터는 IFS=$'\20\09\0A' 로 \0D가 빠져 있었음.
관련글
http://cygwin.com/ml/cygwin-announce/2006-12/msg00026.html
A new release of bash, 3.2.9-10, has been uploaded, replacing 3.2.9-9 as
current.
NEWS:
=====
This is a minor patch release. It undoes the asprintf workaround added in
3.2.5-7, now that cygwin 1.5.23 has been released which overcomes the need
for the workaround. It also improves the postinstall script to deal with
/bin/sh being stuck at version 3.0, which is incompatible with the current
libreadline6.
There are a few things you should be aware of before using this version:
1. When using binary mounts, cygwin programs try to emulate Linux. Bash
on Linux does not understand \r\n line endings, but interprets the \r
literally, which leads to syntax errors or odd variable assignments.
Therefore, you will get the same behavior on Cygwin binary mounts by default.
2. d2u is your friend. You can use it to convert any problematic script
into binary line endings.
3. Cygwin text mounts automatically work with either line ending style,
because the \r is stripped before bash reads the file. If you absolutely
must use files with \r\n line endings, consider mounting the directory
where those files live as a text mount. However, text mounts are not as
well tested or supported on the cygwin mailing list, so you may encounter
other problems with other cygwin tools in those directories.
4. This version of bash has a cygwin-specific shell option, named "igncr"
to force bash to ignore \r, independently of cygwin's mount style. As of
bash-3.2.3-5, it controls regular scripts, command substitution, and
sourced files. I hope to convince the upstream bash maintainer to accept
this patch into the future bash 4.0 even on Linux, rather than keeping it
a cygwin-specific patch, but only time will tell. There are several ways
to activate this option:
4a. For a single affected script, add this line just after the she-bang:
(set -o igncr) 2>/dev/null && set -o igncr; # comment is needed
4b. For a single script, invoke bash explicitly with the shopt, as in
'bash -o igncr ./myscript' rather than the simpler './myscript'.
4c. To affect all scripts, export the environment variable BASH_ENV,
pointing to a file that sets the shell option as desired. Bash will
source this file on startup for every script.
4d. Added in the bash-3.2-2 release: export the environment variable
SHELLOPTS with igncr included in it. It is read-only from within bash,
but you can set it before invoking bash; once in bash, it auto-tracks the
current state of 'set -o igncr' or 'shopt -s igncr'. If exported, then
all bash child processes inherit the same option settings.
5. You can also experiment with the IFS variable for controlling how bash
will treat \r during variable expansion.
6. Normally, cygwin treats DOS-style paths as binary only. This release
of bash includes a hack to check the underlying mount point of files, even
when passed as DOS style paths, but other cygwin tools do not. You are
better off learning how to use POSIX-style paths.
7. There are varying levels of speed at which bash operates. The fastest
is on a binary mount with igncr disabled (the default behavior). Next
would be text mounts with igncr disabled and no \r in the underlying file.
Next would be binary mounts with igncr enabled. And the slowest that bash
will operate is on text mounts with igncr enabled.
8. If you don't like how bash behaves, then propose a patch, rather than
proposing idle ideas. This turn of events has already been talked to
death on the mailing lists by people with many ideas, but few patches.
9. If you forget to read this release announcement, the best you can
expect when you complain to the list is a link back to this email.
Remember, you must not have any bash or /bin/sh instances running when you
upgrade the bash package. This release requires cygwin-1.5.23-1 or
later; and it requires libreadline6-5.2.1-4.
DESCRIPTION:
============
Bash is an sh-compatible shell that incorporates useful features from the
Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE
POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional
improvements over sh for both programming and interactive use. In
addition, most sh scripts can be run by Bash without modification.
As of the bash 3.0 series, cygwin /bin/sh defaults to bash, not ash,
similar to Linux distributions.
'컴퓨터 사용 팁' 카테고리의 다른 글
스펙트럼을 통한 트랜스코드 분석 (0) | 2009.10.14 |
---|---|
사라진 인터넷 익스플로러 (IE) 아이콘 만들기 - 초간단 (0) | 2009.06.19 |
PUSHD POPD (0) | 2009.06.09 |
uTorrent Option Setup Guide (0) | 2009.05.14 |
FLAC 추출 및 변환을 위한 EAC 설정법 (0) | 2009.04.13 |