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?
set -xv
. Use an array instead of a string to store a command with parameters. – choroba Sep 18 '20 at 11:48git log --pretty=format:'%cD%<(20)%cn%f'
and it will work. – binarysta Sep 18 '20 at 11:50eval
fixed the problem! – Danny Sep 20 '20 at 01:52