#!/bin/sh
LOG='log --pretty=format:"%h - %an, %ar : %s"'
git $LOG
I expect this to output an actual git log in the specified format. However, all I get is a fatal argument error.
I have also tried the options below, and they also do not work:
LOG="log --pretty=format:\"%h - %an, %ar : %s\""
LOG='log --pretty=format:\"%h - %an, %ar : %s\"'
However, strangely the script below DOES work, and I don't understand why:
LOG='--pretty=format:"%h - %an, %ar : %s"'
git log "$LOG"
It has been argued that shell is considering the variable to be only one argument, however the following works fine:
LOG1LINE='log --pretty=oneline'
git $LOG1LINE