Mercurial alias using awk

Augie Fackler raf at durin42.com
Tue Jan 5 17:44:36 UTC 2016


> On Jan 4, 2016, at 12:27 PM, Tavis Elliott <TElliott at apptio.com> wrote:
> 
> 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

Try this:

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
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> https://selenic.com/mailman/listinfo/mercurial

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20160105/c3ccb286/attachment.asc>


More information about the Mercurial mailing list