Created
August 20, 2010 21:21
-
-
Save fberger/541224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function export_file { | |
line=$1 | |
file=$(echo $line | awk '{print $3}') | |
prefix=$(echo $line | cut -d':' -f1) | |
eval "export f${counter}=${file}" | |
echo "${prefix}: f${counter} ${file}" | |
let counter=$counter+1 | |
} | |
counter=0 | |
while [ "0" -eq $(eval "test \$f${counter}"; echo $?) ]; do | |
echo "resetting f${counter}" | |
eval "unset f${counter}" | |
let counter=$counter+1 | |
done | |
counter=0 | |
IFS=$'\n' | |
for line in $(git status); do | |
if [[ $line == *"modified:"* ]]; then | |
export_file $line | |
elif [[ $line == *"deleted:"* ]]; then | |
export_file $line | |
else | |
echo $line | |
fi | |
done | |
unset IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When invoked, it creates shell variables for all modified and deleted files in a git status command.