#!/bin/bash repoRoot=$(git rev-parse --show-toplevel) listFilesToSubstitute=$(find -name *.gitsubstitute) listStaticPathFiles=$(git grep -lr --untracked $repoRoot) listStagedFiles=$(git diff --staged --name-only) staticPathSubstitution="\$\$\${GITSUBSTITUTE_REPO_ROOT}" for entryFileToSubstitute in $listFilesToSubstitute; do fullPath="${repoRoot}/${entryFileToSubstitute}" fullPathSubstitute="${repoRoot}/${entryFileToSubstitute%.gitsubstitute}" fileContent=$(<$fullPath) echo "${fileContent//${staticPathSubstitution}/${repoRoot}}" > "${fullPathSubstitute}" done mv hw_platform/platform.tcl TMP1 mv hw_platform/platform.tcl.gitsubstitute TMP2 rm -rf hw_platform mkdir hw_platform mv TMP1 hw_platform/platform.tcl mv TMP2 hw_platform/platform.tcl.gitsubstitute xsct hw_platform/platform.tcl