Bashスクリプトは、行の連続を新しいコマンドとして解釈します。

Bashスクリプトは、行の連続を新しいコマンドとして解釈します。

複数行の cmake コマンドを実行する構成スクリプトを作成しようとしています。

cmake -S . -B build-mac \
    -G Xcode \
    -DCMAKE_CONFIGURATION_TYPES="Debug;Release" \
    -DCMAKE_INSTALL_PREFIX=install/mac \
    -DCMAKE_TOOLCHAIN_FILE=Modules/Darwin.cmake

しかし、エラーが発生しました。

" does not exist.source directory "/Users/.../scripts/
Specify --help for usage, or press the help button on the CMake GUI.
./release-mac.bash: line 2: -G: command not found
: command not found line 3: -DCMAKE_CONFIGURATION_TYPES=Debug;Release
: No such file or directory -DCMAKE_INSTALL_PREFIX=install/mac
: No such file or directory -DCMAKE_TOOLCHAIN_FILE=Modules/Darwin.cmake

したがって、最初の行以降のすべての行は新しいコマンドとして解釈されます。行連続が機能しないのはなぜですか?

ベストアンサー1

私のスクリプトにWindowsスタイルの行末があります。

この投稿私に提案された便利なトラブルシューティングコマンド:

file <file>
cat -v <file>
od -t c <file>

おすすめ記事