Mercurial alias using awk

Tavis Elliott TElliott at apptio.com
Mon Jan 4 17:27:54 UTC 2016


Due to https://bz.mercurial-scm.org/show_bug.cgi?id=4980 I need a way for my team to clean up bookmarks locally.  I have the following alias:

bookrefresh=! for bm in `$HG bookmarks | awk '{print$1}'`; do $HG bookmark -d $bm; done; $HG pull

This works as a regular shell script.

This "works", but attempts to delete the revs for each bookmark too:
> hg bookrefresh

abort: bookmark 'xxxxx:xxxxxxxxxxx' does not exist
abort: bookmark 'xxxxx:xxxxxxxxxxx' does not exist
pulling from https://hg.apptio.com/hg/biit
searching for changes
no changes found
adding remote bookmark bookmark1
adding remote bookmark bookmark2

It seems like mercurial is expanding the $1 argument to awk before the command is executed (https://www.selenic.com/mercurial/hgrc.5.html#alias indicates as such) but I must be missing how to make it stop doing that.

This actually works, but is pretty annoying:

> hg bookrefresh \$1

Is there a way to tell mercurial to please not expand $1 in the middle of an awk?

-Tavis


More information about the Mercurial mailing list