0

The git log command can specify a custom format, ie,

git log --pretty=format:'%cD %<(20)%cn %f'

Will format the log files into columns.

But I can't get this to work in a two line bash script:

#!/bin/bash
set -x
CMD="git log --pretty=format:'%cD %<(20)%cn %f'"
$CMD

It looks like bash is adding backslashes in front of '--' and single quotes...

+ CMD='git log --pretty=format:'\''%cD %<(20)%cn %f'\'''
+ git log '--pretty=format:'\''%cD' '%<(20)%cn' '%f'\'''
fatal: ambiguous argument '%<(20)%cn': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I've tried escaping different parts of the command but can't git it to work.

Any ideas?

Danny
  • 603
  • 9
  • 19

0 Answers0