0

I have an alias that does an ssh into a machine and executes 1 line of code as following:

alias posts-update= 'ssh [email protected] "cd /var/www/blog/posts && git pull"'

This works perfectly if executed manually but if I try to use the posts-update alias, it does nothing and prints nothing

5
  • 2
    Do you really have a space between the = and the opening quote? gnu.org/software/bash/manual/bashref.html#index-alias Mar 29, 2014 at 11:46
  • 2
    Note that the command can be written in a slightly more straightforward way: ssh user@host git -C /var/www/blog/posts pull. Mar 29, 2014 at 11:50
  • 1
    @DanielAndersson: The -C option was added recently (in 1.8, I think?) so it might not always work. [I've seen systems with git 1.6…] Mar 29, 2014 at 13:10
  • @glennjackman ya, somehow managed to missed that. Mar 29, 2014 at 13:10
  • @grawity: All right, I mostly use Mercurial in a similar way that has had such a switch for a long time. I looked it up for Git in the manual on my local system as I wrote the above, since I just assumed it would have a similar switch :-) . Stack Overflow has a question that confirms that it is quite recent; only since 1.8.5, actually. Mar 29, 2014 at 16:07

1 Answer 1

2

There is a space after the = in your command, splitting the parameter into two:

This causes alias to alias posts-update to nothing (as there is nothing following the =). It should also print an error message about the second parameter, which doesn't have a = in it so alias thinks it's an existing alias name to be described.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .