ドットファイルスクリプトの作成

ドットファイルスクリプトの作成

私はこれを尋ねる質問それはすべてです。ここまでは、私のスクリプトの現在のバージョンと私が望む作業があります。デバッグとテストに関するアドバイスを求めています。これをさらに行うと、おそらく-fnこのアイテムを削除します。邪魔になるからです。これは、ファイルを一時ディレクトリに移動してから元に戻す必要があるためです。

#!/bin/bash

set -e

function makeLinks() {
    ln -sfn ~/Documents/Dotfiles/.bash_profile ~/.bash_profile\
    ln -sfn ~/Documents/Dotfiles/.gitconfig ~/.gitconfig\
    ln -sfn ~/Documents/Dotfiles/.gitignore_global ~/.gitignore_global
    source ~/.bash_profile;
    }

    read -rp "This may overwrite existing files. Are you sure? (y/n) " -n 1;
    echo "";
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        makeLinks
    fi;

ベストアンサー1

拡張注:末尾のバックスラッシュのため、3つのlnコマンドは1行として扱われます。あなたはこれをしたくありません。あなたは3つの異なる行が欲しい。したがって、ここに3行を表示すると、次のように解析されます。

$ echo ln -sfn ~/Documents/Dotfiles/.bash_profile ~/.bash_profile\
>     ln -sfn ~/Documents/Dotfiles/.gitconfig ~/.gitconfig\
>     ln -sfn ~/Documents/Dotfiles/.gitignore_global ~/.gitignore_global
ln -sfn /cygdrive/d/home/prateek/Documents/Dotfiles/.bash_profile /cygdrive/d/home/prateek/.bash_profile ln -sfn /cygdrive/d/home/prateek/Documents/Dotfiles/.gitconfig /cygdrive/d/home/prateek/.gitconfig ln -sfn /cygdrive/d/home/prateek/Documents/Dotfiles/.gitignore_global /cygdrive/d/home/prateek/.gitignore_global

echo1行にリストされているすべてのコマンドの出力を表示できます。バックスラッシュを削除してもこの問題は発生しません。各コマンドは個別に処理されます。

おすすめ記事