도트파일 스크립트 만들기

도트파일 스크립트 만들기

나는 이것을 물었다.질문SO에 끝났고 그리 멀지 않았습니다. 여기에 내 스크립트의 현재 버전과 내가 원하는 작업이 있습니다. 디버깅 및 테스트에 대한 제안이 제가 찾고 있는 것입니다. -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

설명을 확장하면 후행 백슬래시로 인해 세 ln명령이 한 줄로 처리됩니다. 당신은 그것을 원하지 않습니다. 당신은 세 가지 다른 라인을 원합니다. 따라서 여기에 세 줄을 표시하면 구문 분석 방법이 표시됩니다.

$ 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

모든 명령 의 출력이 echo한 줄에 나열되는 것을 볼 수 있습니다. 백슬래시를 제거해도 해당 동작이 발생하지 않습니다. 각 명령은 별도로 처리됩니다.

관련 정보