Perfectly Imperfect Bash
A quick and dirty nerdy reflection on some Perfectly Imperfect Bash I just wrote while exploring the skip-worktree flag in Git:
git ls-files -v | grep 'S ' | xargs -n 1 git update-index --no-skip-worktree
To the uninitiated:
git ls-files -v
lists all files in my git workspace, prefixed with a single-letter flag.grep 'S '
filters based on those flags, looking for any file prefixed with anS
. I've been messing with these files, and want to revert that flag.xargs -n 1
runs the final git command once per line.git update-index --no-skip-worktree
performs the actual work of resetting the errant flag.
That boldfaced word in part 3 is the crux of my reflection. Part 4 would actually receive two arguments: the flag and the file itself. Upon brief reflection I asked an all-important question for engineers to ask: "Who cares?" I realized Git would attempt to interact with a file named S
, complaining at its non-existence but continuing with the real file anyway. I could spend the additional few minutes doing it the Right Way, but...
Who cares?
Maybe you do. Maybe you find it irresponsible that I'd make Git complain so much. If that sounds like you, here's your solution.
git ls-files -v | grep 'S ' | xargs -n 1 git update-index --no-skip-worktree 2> /dev/null
You're welcome. Go forth and keep shipping.
9th of June, 2014