Reputation: 1535
recently i started exploring shell scripting.
i wrote a simple shell script(git hook) to check which are all the modified files in my local repository.Shell script works fine.
my script
#/usr/bin/env bash
git fetch && git log ORIG_HEAD..origin/master --pretty=format:"%s - %ar by %an %h"
output
post-merge check 7 - 30 seconds ago by xyz f917898
post-merge check 6 - 54 seconds ago by xyz 98399c8
I want to mail output of my shell script to my friend.
i tried like this
#/usr/bin/env bash
changed_files = `git fetch && git log ORIG_HEAD..origin/master --pretty=format:"%s - %ar by %an %h"`
echo "$changed_files" | mailx -s "changes made to local repo" [email protected]
but it is leading me to
.git/hooks/post-merge: 2: .git/hooks/post-merge: changed_files: not found
can any body suggest me how to achieve this?
I can do this with writing output to an text file and attach that file and send a mail. But i am curious about sending in a single shot.
Thank you
Upvotes: 0
Views: 59
Reputation: 881263
Get rid of those spaces around the =
:
changed_files=`git ...
In bash
, the line:
changed_files = something
means to run the changed_files
executable (which doesn't exist in this case, hence the error), passing two parameters, =
and something
.
Upvotes: 3