1

I asked this question over on SO and didn't get very far; here is the current version of my script and what I'd like the do. Suggestions for debugging and testing are what I'm looking for. I'll probably remove -fn while working on this more, as it just gets in the way - had to move files into a temp directory and then back again in order for anything to work.

#!/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;
  • 5
    remove trailing blackslashes – Ipor Sircer Sep 22 '16 at 16:21
1

To expand on the comment: the trailing backslashes cause the three ln commands to be treated as one line. You don't want that. You want three different lines. So, when I echo the three lines here is how they are parsed.

$ 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

You can see as the output of the echo all the commands are listed on one line. Removing the backslashes won't cause that behavior. Each command will be treated separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.