Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to have an alias that execute a command and then whether it fails or no it execute other commands that depends on the success of each other.

So I have something like that in .gitconfig

getpull = !sh -c 'git remote add $0 $1; git fetch $0 && git checkout -b $2 $0/$2'

With that command I get the following error (I donno as when I copy this to the shell it works fine):

sh -c 'git remote add $0 $1: 1: sh -c 'git remote add $0 $1: Syntax     error: Unterminated quoted string
share|improve this question

2 Answers 2

up vote 2 down vote accepted

I figured it out, it seems something with .gitconfig parser and to solve it we just need to wrap the whole command with double quotes as follow

"!sh -c 'git remote add $0 $1; git fetch $0 && git checkout -b $2 $0/$2'"
share|improve this answer

The ; semicolon starts a comment that terminates your Git alias early hereby making it incomplete at the time Git tries to run the external shell command you aliased.

The manual page of the git-config command states that a ; semicolon starts a comment that extends until the end of a line because Git configuration files are written in the INI format.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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